Bug 1036777 - Fix string casts to be safe per-XPIDL. r=neil
authorBobby Holley <bobbyholley@gmail.com>
Fri, 11 Jul 2014 19:21:23 -0700
changeset 215639 a0f06500edd1713c44e70507d2b0efea8cfdfb10
parent 215638 18783d1e2a77351c3a5a86ab32d88c8e82364c99
child 215640 797f916f7380a7e4d5b292fab9fc7cf6f938525d
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs1036777
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1036777 - Fix string casts to be safe per-XPIDL. r=neil These types map to nsAString and nsACString respectively.
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -509,17 +509,17 @@ XPCConvert::JSData2Native(void* d, Handl
 
             length = JS_GetStringLength(str);
             if (!length) {
                 (**((nsAString**)d)).Truncate();
                 return true;
             }
         }
 
-        nsString* ws = *((nsString**)d);
+        nsAString* ws = *((nsAString**)d);
 
         if (!str) {
             ws->AssignLiteral(MOZ_UTF16("undefined"));
         } else if (XPCStringConvert::IsDOMString(str)) {
             // The characters represent an existing nsStringBuffer that
             // was shared by XPCStringConvert::ReadableToJSVal.
             const jschar *chars = JS_GetTwoByteExternalStringChars(str);
             nsStringBuffer::FromData((void *)chars)->ToString(length, *ws);
@@ -621,21 +621,20 @@ XPCConvert::JSData2Native(void* d, Handl
             return true;
         }
 
         JSFlatString *flat = JS_FlattenString(cx, str);
         if (!flat)
             return false;
 
         size_t utf8Length = JS::GetDeflatedUTF8StringLength(flat);
-        nsCString *rs = *((nsCString**)d);
+        nsACString *rs = *((nsACString**)d);
         rs->SetLength(utf8Length);
 
         JS::DeflateStringToUTF8Buffer(flat, mozilla::RangedPtr<char>(rs->BeginWriting(), utf8Length));
-        MOZ_ASSERT(rs->get()[utf8Length] == '\0');
 
         return true;
     }
 
     case nsXPTType::T_CSTRING:
     {
         if (s.isNull() || s.isUndefined()) {
             nsACString* rs = *((nsACString**)d);