Fix hilarious bug in js_malloc: it fails once every 2^32 allocations in DEBUG builds. Bug 730270, r=luke.
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 01 Mar 2012 09:01:45 -0600
changeset 90966 b1fd65f6165d07fba297e53207eab49fba929bf6
parent 90965 91ca0cc06f46dc519ee50403131b7f8fd3e4089d
child 90967 21f05e099a3627698b71c3a91a9fffce7f85147b
push idunknown
push userunknown
push dateunknown
reviewersluke
bugs730270
milestone13.0a1
Fix hilarious bug in js_malloc: it fails once every 2^32 allocations in DEBUG builds. Bug 730270, r=luke.
js/public/Utility.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -110,17 +110,17 @@ extern JS_PUBLIC_API(void) JS_Abort(void
  * In order to test OOM conditions, when the shell command-line option
  * |-A NUM| is passed, we fail continuously after the NUM'th allocation.
  */
 extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set from shell/js.cpp */
 extern JS_PUBLIC_DATA(uint32_t) OOM_counter; /* data race, who cares. */
 #  define JS_OOM_POSSIBLY_FAIL() \
     do \
     { \
-        if (OOM_counter++ >= OOM_maxAllocations) { \
+        if (++OOM_counter > OOM_maxAllocations) { \
             return NULL; \
         } \
     } while (0)
 
 # else
 #  define JS_OOM_POSSIBLY_FAIL() do {} while(0)
 # endif