Bug 1533288 - Don't assume HasMoreElements() is called before GetNext() in nsIEHistoryEnumerator. r=jaws

Differential Revision: https://phabricator.services.mozilla.com/D22843

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Noorenberghe 2019-03-13 03:11:52 +00:00
Родитель 67e8bf685b
Коммит 84b6afec6f
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -93,7 +93,21 @@ 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.