mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 04:27:41 +00:00
Bug 785060 - Check for allocation failure in JS_NewUCStringCopyZ calls; r=Ms2ger
This commit is contained in:
parent
b62b852e17
commit
ec1be4c9ac
@ -1492,6 +1492,11 @@ nsHTMLMediaElement::BuildObjectFromTags(nsCStringHashKey::KeyType aKey,
|
||||
|
||||
nsString wideValue = NS_ConvertUTF8toUTF16(aValue);
|
||||
JSString* string = JS_NewUCStringCopyZ(args->cx, wideValue.Data());
|
||||
if (!string) {
|
||||
NS_WARNING("Failed to perform string copy");
|
||||
args->error = true;
|
||||
return PL_DHASH_STOP;
|
||||
}
|
||||
JS::Value value = STRING_TO_JSVAL(string);
|
||||
if (!JS_DefineProperty(args->cx, args->tags, aKey.Data(), value,
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
|
@ -631,6 +631,7 @@ bool SetStringProperty(JSContext *cx, JSObject *aObject, const char *aProperty,
|
||||
return true;
|
||||
}
|
||||
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
|
||||
NS_ENSURE_TRUE(strValue, false);
|
||||
jsval valValue = STRING_TO_JSVAL(strValue);
|
||||
return JS_SetProperty(cx, aObject, aProperty, &valValue);
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
|
||||
unicodeMsg.AssignWithConversion(msg);
|
||||
JSAutoRequest ar(cx);
|
||||
JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, (jschar*) unicodeMsg.get());
|
||||
NS_ENSURE_TRUE(jsMsgStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
params[0] = BOOLEAN_TO_JSVAL(server);
|
||||
params[1] = STRING_TO_JSVAL(jsMsgStr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user