зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1330759 part 2. Fix XPCConvert::JSData2Native to not share an external string stringbuffer if it would create a non-null-terminated string. r=froydnj
This commit is contained in:
Родитель
10ac0b56b4
Коммит
ced1c6138f
|
@ -524,7 +524,13 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
|||
// The characters represent an existing nsStringBuffer that
|
||||
// was shared by XPCStringConvert::ReadableToJSVal.
|
||||
const char16_t* chars = JS_GetTwoByteExternalStringChars(str);
|
||||
if (chars[length] == '\0') {
|
||||
// Safe to share the buffer.
|
||||
nsStringBuffer::FromData((void*)chars)->ToString(length, *ws);
|
||||
} else {
|
||||
// We have to copy to ensure null-termination.
|
||||
ws->Assign(chars, length);
|
||||
}
|
||||
} else if (XPCStringConvert::IsLiteral(str)) {
|
||||
// The characters represent a literal char16_t string constant
|
||||
// compiled into libxul, such as the string "undefined" above.
|
||||
|
|
Загрузка…
Ссылка в новой задаче