Bug 1159604: Use a fallible allocation in nsClipboard::GetGlobalData. r=bbondy

This commit is contained in:
David Major 2015-07-22 10:31:17 -04:00
parent 0e505c7df5
commit 5ea519db71

View File

@ -282,7 +282,7 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, uint32_t * aLe
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