Bug 1140317: Make sure chars created by DecompileValueGenerator won't ever leak; r=Waldo
This commit is contained in:
@@ -94,10 +94,11 @@ js::NonNullObject(JSContext *cx, const Value &v)
|
||||
{
|
||||
if (v.isPrimitive()) {
|
||||
RootedValue value(cx, v);
|
||||
char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, NullPtr());
|
||||
UniquePtr<char[], JS::FreePolicy> bytes =
|
||||
DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, NullPtr());
|
||||
if (!bytes)
|
||||
return nullptr;
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes);
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
|
||||
return nullptr;
|
||||
}
|
||||
return &v.toObject();
|
||||
@@ -249,12 +250,12 @@ js::GetFirstArgumentAsObject(JSContext *cx, const CallArgs &args, const char *me
|
||||
|
||||
HandleValue v = args[0];
|
||||
if (!v.isObject()) {
|
||||
char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr());
|
||||
UniquePtr<char[], JS::FreePolicy> bytes =
|
||||
DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr());
|
||||
if (!bytes)
|
||||
return false;
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
|
||||
bytes, "not an object");
|
||||
js_free(bytes);
|
||||
bytes.get(), "not an object");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -285,10 +286,11 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
|
||||
|
||||
/* 8.10.5 step 1 */
|
||||
if (v.isPrimitive()) {
|
||||
char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr());
|
||||
UniquePtr<char[], JS::FreePolicy> bytes =
|
||||
DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr());
|
||||
if (!bytes)
|
||||
return false;
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes);
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes.get());
|
||||
return false;
|
||||
}
|
||||
RootedObject desc(cx, &v.toObject());
|
||||
|
||||
Reference in New Issue
Block a user