Bug 1142816 - Fix leaks in js/src/jsapi-tests/testGCHeapPostBarriers.cpp. r=erahm
☠☠ backed out by a7e851e4c2d2 ☠ ☠
authorJinank Jain <jinank94@gmail.com>
Mon, 18 May 2015 20:01:26 +0200
changeset 275926 e602cb65a030c19fecfa912be51f92fc0160d70f
parent 275925 b77ba04e3d879c22473234a84ee2bffa93d59ebf
child 275927 b30c80ba44f3f8ada4c03e8bffbb65a9f161ae47
push idunknown
push userunknown
push dateunknown
reviewerserahm
bugs1142816
milestone41.0a1
Bug 1142816 - Fix leaks in js/src/jsapi-tests/testGCHeapPostBarriers.cpp. r=erahm
js/src/jsapi-tests/testGCHeapPostBarriers.cpp
--- a/js/src/jsapi-tests/testGCHeapPostBarriers.cpp
+++ b/js/src/jsapi-tests/testGCHeapPostBarriers.cpp
@@ -3,16 +3,18 @@
 */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "js/RootingAPI.h"
 #include "jsapi-tests/tests.h"
 
+using mozilla::ScopedDeletePtr;
+
 BEGIN_TEST(testGCHeapPostBarriers)
 {
 #ifdef JS_GC_ZEAL
     AutoLeaveZeal nozeal(cx);
 #endif /* JS_GC_ZEAL */
 
     /* Sanity check - objects start in the nursery and then become tenured. */
     JS_GC(cx->runtime());
@@ -39,18 +41,18 @@ Passthrough(bool value)
 template <typename T>
 bool
 TestHeapPostBarriers(T initialObj)
 {
     CHECK(initialObj != nullptr);
     CHECK(js::gc::IsInsideNursery(initialObj));
 
     /* Construct Heap<> wrapper. */
-    JS::Heap<T>* heapData = new JS::Heap<T>();
-    CHECK(heapData);
+    ScopedDeletePtr<JS::Heap<T>> heapData(new JS::Heap<T>);
+    CHECK(heapData.get());
     CHECK(Passthrough(heapData->get() == nullptr));
     *heapData = initialObj;
 
     /* Store the pointer as an integer so that the hazard analysis will miss it. */
     uintptr_t initialObjAsInt = uintptr_t(initialObj);
 
     /* Perform minor GC and check heap wrapper is udated with new pointer. */
     cx->minorGC(JS::gcreason::API);