Bug 1159604: Use a fallible allocation in nsClipboard::GetGlobalData. r=bbondy
authorDavid Major <dmajor@mozilla.com>
Wed, 22 Jul 2015 10:31:17 -0400
changeset 254106 275301e64d0e33dcac84952899a1061af1c7a407
parent 254105 89232f8a699933612fc6038bd82635f2df06645b
child 254107 beed0226c5970b63deef00143d7077d59899b42c
push id62658
push userdmajor@mozilla.com
push dateWed, 22 Jul 2015 14:32:05 +0000
treeherdermozilla-inbound@275301e64d0e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs1159604
milestone42.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 1159604: Use a fallible allocation in nsClipboard::GetGlobalData. r=bbondy
widget/windows/nsClipboard.cpp
--- a/widget/windows/nsClipboard.cpp
+++ b/widget/windows/nsClipboard.cpp
@@ -277,17 +277,17 @@ nsresult nsClipboard::GetGlobalData(HGLO
   // Allocate a new memory buffer and copy the data from global memory.
   // Recall that win98 allocates to nearest DWORD boundary. As a safety
   // precaution, allocate an extra 2 bytes (but don't report them!) and
   // null them out to ensure that all of our strlen calls will succeed.
   nsresult  result = NS_ERROR_FAILURE;
   if (aHGBL != nullptr) {
     LPSTR lpStr = (LPSTR) GlobalLock(aHGBL);
     DWORD allocSize = GlobalSize(aHGBL);
-    char* data = static_cast<char*>(moz_xmalloc(allocSize + sizeof(char16_t)));
+    char* data = static_cast<char*>(malloc(allocSize + sizeof(char16_t)));
     if ( data ) {    
       memcpy ( data, lpStr, allocSize );
       data[allocSize] = data[allocSize + 1] = '\0';     // null terminate for safety
 
       GlobalUnlock(aHGBL);
       *aData = data;
       *aLen = allocSize;