diff --git a/js/src/jsapi-tests/testMutedErrors.cpp b/js/src/jsapi-tests/testMutedErrors.cpp index f691ba115c10..44bc6154b11b 100644 --- a/js/src/jsapi-tests/testMutedErrors.cpp +++ b/js/src/jsapi-tests/testMutedErrors.cpp @@ -5,6 +5,8 @@ #include "jsfriendapi.h" #include "jsapi-tests/tests.h" +using mozilla::UniquePtr; + static bool sErrorReportMuted = false; BEGIN_TEST(testMutedErrors) { @@ -45,7 +47,7 @@ bool eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval) { size_t len = strlen(asciiChars); - char16_t* chars = new char16_t[len+1]; + UniquePtr chars(new char16_t[len+1]); for (size_t i = 0; i < len; ++i) chars[i] = asciiChars[i]; chars[len] = 0; @@ -60,10 +62,7 @@ eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval) options.setMutedErrors(mutedErrors) .setFileAndLine("", 0); - bool ok = JS::Evaluate(cx, options, chars, len, rval); - - delete[] chars; - return ok; + return JS::Evaluate(cx, options, chars.get(), len, rval); } bool