Bug 1166742 - nsFilePickerProxy::SimpleEnumerator should return false when HasMoreElements is called on an empty array, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 20 May 2015 16:18:47 +0100
changeset 275557 9ce09518b75258e232c03c676c3a6d60edd4f050
parent 275556 ffb30fa0f7fc59eebce42898030fb87f8c6c6f62
child 275558 9dfe96e082e6cfd57345ba255b7e64c7db62333f
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1166742
milestone41.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 1166742 - nsFilePickerProxy::SimpleEnumerator should return false when HasMoreElements is called on an empty array, r=smaug
widget/nsFilePickerProxy.cpp
--- a/widget/nsFilePickerProxy.cpp
+++ b/widget/nsFilePickerProxy.cpp
@@ -202,23 +202,25 @@ public:
     : mFiles(aFiles)
     , mIndex(0)
   {}
 
   NS_IMETHOD
   HasMoreElements(bool* aRetvalue) override
   {
     MOZ_ASSERT(aRetvalue);
-    *aRetvalue = mFiles.Length() >= mIndex;
+    *aRetvalue = mIndex < mFiles.Length();
     return NS_OK;
   }
 
   NS_IMETHOD
   GetNext(nsISupports** aSupports) override
   {
+    NS_ENSURE_TRUE(mIndex < mFiles.Length(), NS_ERROR_FAILURE);
+
     nsCOMPtr<nsIDOMBlob> blob = mFiles[mIndex++].get();
     blob.forget(aSupports);
     return NS_OK;
   }
 
 private:
   ~SimpleEnumerator()
   {}