mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1471900: Change return type of JS_EncodeStringToBuffer to bool. r=jandem
This commit is contained in:
parent
4e2f73b382
commit
781fc92292
@ -2893,7 +2893,9 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_EncodeStringToBuffer(cx, s, result.BeginWriting(), length);
|
||||
if (!JS_EncodeStringToBuffer(cx, s, result.BeginWriting(), length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -6131,7 +6131,7 @@ JS_GetStringEncodingLength(JSContext* cx, JSString* str)
|
||||
return str->length();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(size_t)
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_EncodeStringToBuffer(JSContext* cx, JSString* str, char* buffer, size_t length)
|
||||
{
|
||||
AssertHeapIsIdle();
|
||||
@ -6139,7 +6139,7 @@ JS_EncodeStringToBuffer(JSContext* cx, JSString* str, char* buffer, size_t lengt
|
||||
|
||||
JSLinearString* linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
return size_t(-1);
|
||||
return false;
|
||||
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
size_t writeLength = Min(linear->length(), length);
|
||||
@ -6151,7 +6151,7 @@ JS_EncodeStringToBuffer(JSContext* cx, JSString* str, char* buffer, size_t lengt
|
||||
for (size_t i = 0; i < writeLength; i++)
|
||||
buffer[i] = char(src[i]);
|
||||
}
|
||||
return linear->length();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::Symbol*)
|
||||
|
@ -4636,7 +4636,7 @@ JS_GetStringEncodingLength(JSContext* cx, JSString* str);
|
||||
* length parameter, the string will be cut and only length bytes will be
|
||||
* written into the buffer.
|
||||
*/
|
||||
JS_PUBLIC_API(size_t)
|
||||
MOZ_MUST_USE JS_PUBLIC_API(bool)
|
||||
JS_EncodeStringToBuffer(JSContext* cx, JSString* str, char* buffer, size_t length);
|
||||
|
||||
class MOZ_RAII JSAutoByteString
|
||||
|
@ -642,7 +642,10 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
if (!buffer) {
|
||||
return false;
|
||||
}
|
||||
JS_EncodeStringToBuffer(cx, str, buffer, length);
|
||||
if (!JS_EncodeStringToBuffer(cx, str, buffer, length)) {
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
buffer[length] = '\0';
|
||||
*((void**)d) = buffer;
|
||||
return true;
|
||||
@ -750,7 +753,9 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
||||
if (rs->Length() != uint32_t(length)) {
|
||||
return false;
|
||||
}
|
||||
JS_EncodeStringToBuffer(cx, str, rs->BeginWriting(), length);
|
||||
if (!JS_EncodeStringToBuffer(cx, str, rs->BeginWriting(), length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user