mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1588810 - Fix ctypes UnicodeToNative callback to not assume null-terminated strings. r=bzbarsky
Bug 1586683 replaced the JS_FlattenString in the caller with JS_EnsureLinearString but I wasn't aware of the nsDependentString vs nsDependentSubstring distinction. This fixes assertion failures when starting the browser with non-null-terminated JS strings. Differential Revision: https://phabricator.services.mozilla.com/D49297 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9d573b660f
commit
026691dc76
@ -24,7 +24,7 @@ namespace {
|
||||
|
||||
char* UnicodeToNative(JSContext* aCx, const char16_t* aSource,
|
||||
size_t aSourceLen) {
|
||||
nsDependentString unicode(aSource, aSourceLen);
|
||||
nsDependentSubstring unicode(aSource, aSourceLen);
|
||||
|
||||
nsAutoCString native;
|
||||
if (NS_FAILED(NS_CopyUnicodeToNative(unicode, native))) {
|
||||
|
@ -20,7 +20,7 @@ namespace ctypes {
|
||||
static char* UnicodeToNative(JSContext* cx, const char16_t* source,
|
||||
size_t slen) {
|
||||
nsAutoCString native;
|
||||
nsDependentString unicode(reinterpret_cast<const char16_t*>(source), slen);
|
||||
nsDependentSubstring unicode(source, slen);
|
||||
nsresult rv = NS_CopyUnicodeToNative(unicode, native);
|
||||
if (NS_FAILED(rv)) {
|
||||
JS_ReportErrorASCII(cx, "could not convert string to native charset");
|
||||
|
Loading…
Reference in New Issue
Block a user