Prefast: Add null check prior to writing into allocated BSTR.
authorsfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2007 17:13:17 +0000 (17:13 +0000)
committersfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2007 17:13:17 +0000 (17:13 +0000)
        Reviewed by Darin.

        * MarshallingHelpers.cpp:
        (MarshallingHelpers::CFStringRefToBSTR):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23819 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/MarshallingHelpers.cpp

index df932e9..8f1249d 100644 (file)
@@ -1,5 +1,14 @@
 2007-06-27  Steve Falkenburg  <sfalken@apple.com>
 
+        Prefast: Add null check prior to writing into allocated BSTR.
+        
+        Reviewed by Darin.
+
+        * MarshallingHelpers.cpp:
+        (MarshallingHelpers::CFStringRefToBSTR):
+
+2007-06-27  Steve Falkenburg  <sfalken@apple.com>
+
         Prefast: Add error handling for SysAllocStringLen where the string length is determined by website content.
 
         Reviewed by Sam, Darin.
index 00ee048..6591a0f 100644 (file)
@@ -100,8 +100,10 @@ BSTR MarshallingHelpers::CFStringRefToBSTR(CFStringRef str)
 
     CFIndex length = CFStringGetLength(str);
     BSTR bstr = SysAllocStringLen(0, length);
-    CFStringGetCharacters(str, CFRangeMake(0, length), (UniChar*)bstr);
-    bstr[length] = 0;
+    if (bstr) {
+        CFStringGetCharacters(str, CFRangeMake(0, length), (UniChar*)bstr);
+        bstr[length] = 0;
+    }
     return bstr;
 }