Bug 1533288 - Don't assume HasMoreElements() is called before GetNext() in nsIEHistoryEnumerator. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 13 Mar 2019 03:11:52 +0000
changeset 521648 5a255779e2a7
parent 521647 4ac13d1f0d7c
child 521649 7651c91b361b
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1533288
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533288 - Don't assume HasMoreElements() is called before GetNext() in nsIEHistoryEnumerator. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D22843
browser/components/migration/nsIEHistoryEnumerator.cpp
--- a/browser/components/migration/nsIEHistoryEnumerator.cpp
+++ b/browser/components/migration/nsIEHistoryEnumerator.cpp
@@ -88,16 +88,30 @@ nsIEHistoryEnumerator::HasMoreElements(b
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIEHistoryEnumerator::GetNext(nsISupports** _retval) {
   *_retval = nullptr;
 
-  if (!mCachedNextEntry) return NS_ERROR_FAILURE;
+  EnsureInitialized();
+  MOZ_ASSERT(mURLEnumerator,
+             "Should have instanced an IE History URLEnumerator");
+  if (!mURLEnumerator) return NS_OK;
+
+  if (!mCachedNextEntry) {
+    bool hasMore = false;
+    nsresult rv = this->HasMoreElements(&hasMore);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    if (!hasMore) {
+      return NS_ERROR_FAILURE;
+    }
+  }
 
   NS_ADDREF(*_retval = mCachedNextEntry);
   // Release the cached entry, so it can't be returned twice.
   mCachedNextEntry = nullptr;
 
   return NS_OK;
 }