Bug 682727 - Handle OOM in xpc_qsDOMString and xpc_qsAUTF8String
authorMichal Novotny <michal.novotny@gmail.com>
Fri, 30 Sep 2011 21:13:55 +0200
changeset 78575 dd0cc50e9fe6dbe6dcfe298f026b4c0235f55c3f
parent 78574 e87bbd84ba8748561ac76ea76cf916c5a4ed8fdb
child 78576 6d1c0e678b613589b601606da0552513d71b9d4c
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs682727
milestone10.0a1
Bug 682727 - Handle OOM in xpc_qsDOMString and xpc_qsAUTF8String
js/src/xpconnect/src/xpcquickstubs.cpp
--- a/js/src/xpconnect/src/xpcquickstubs.cpp
+++ b/js/src/xpconnect/src/xpcquickstubs.cpp
@@ -721,18 +721,20 @@ xpc_qsDOMString::xpc_qsDOMString(JSConte
     // From the T_DOMSTRING case in XPCConvert::JSData2Native.
     JSString *s = InitOrStringify<traits>(cx, v, pval, nullBehavior,
                                           undefinedBehavior);
     if (!s)
         return;
 
     size_t len;
     const jschar *chars = JS_GetStringCharsZAndLength(cx, s, &len);
-    if (!chars)
+    if (!chars) {
+        mValid = JS_FALSE;
         return;
+    }
 
     new(mBuf) implementation_type(chars, len);
     mValid = JS_TRUE;
 }
 
 xpc_qsACString::xpc_qsACString(JSContext *cx, jsval v, jsval *pval,
                                StringificationBehavior nullBehavior,
                                StringificationBehavior undefinedBehavior)
@@ -767,18 +769,20 @@ xpc_qsAUTF8String::xpc_qsAUTF8String(JSC
     typedef nsCharTraits<PRUnichar> traits;
     // From the T_UTF8STRING  case in XPCConvert::JSData2Native.
     JSString *s = InitOrStringify<traits>(cx, v, pval, eNull, eNull);
     if (!s)
         return;
 
     size_t len;
     const PRUnichar *chars = JS_GetStringCharsZAndLength(cx, s, &len);
-    if (!chars)
+    if (!chars) {
+        mValid = JS_FALSE;
         return;
+    }
 
     new(mBuf) implementation_type(chars, len);
     mValid = JS_TRUE;
 }
 
 static nsresult
 getNative(nsISupports *idobj,
           QITableEntry* entries,