зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 47aeeaf1c35b (bug 1513201) for build bustage. CLOSED TREE
This commit is contained in:
Родитель
cbad78f7c3
Коммит
71501396ae
|
@ -280,18 +280,16 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void** aData,
|
||||||
uint32_t* aLen) {
|
uint32_t* aLen) {
|
||||||
// Allocate a new memory buffer and copy the data from global memory.
|
// Allocate a new memory buffer and copy the data from global memory.
|
||||||
// Recall that win98 allocates to nearest DWORD boundary. As a safety
|
// Recall that win98 allocates to nearest DWORD boundary. As a safety
|
||||||
// precaution, allocate an extra 3 bytes (but don't report them in |aLen|!)
|
// precaution, allocate an extra 2 bytes (but don't report them!) and
|
||||||
// and null them out to ensure that all of our NS_strlen calls will succeed.
|
// null them out to ensure that all of our strlen calls will succeed.
|
||||||
// NS_strlen operates on char16_t, so we need 3 NUL bytes to ensure it finds
|
|
||||||
// a full NUL char16_t when |*aLen| is odd.
|
|
||||||
nsresult result = NS_ERROR_FAILURE;
|
nsresult result = NS_ERROR_FAILURE;
|
||||||
if (aHGBL != nullptr) {
|
if (aHGBL != nullptr) {
|
||||||
LPSTR lpStr = (LPSTR)GlobalLock(aHGBL);
|
LPSTR lpStr = (LPSTR)GlobalLock(aHGBL);
|
||||||
DWORD allocSize = GlobalSize(aHGBL);
|
DWORD allocSize = GlobalSize(aHGBL);
|
||||||
char* data = static_cast<char*>(malloc(allocSize + 3));
|
char* data = static_cast<char*>(malloc(allocSize + sizeof(char16_t)));
|
||||||
if (data) {
|
if (data) {
|
||||||
memcpy(data, lpStr, allocSize);
|
memcpy(data, lpStr, allocSize);
|
||||||
data[allocSize] = data[allocSize + 1] = data[allocSize + 2]
|
data[allocSize] = data[allocSize + 1] =
|
||||||
'\0'; // null terminate for safety
|
'\0'; // null terminate for safety
|
||||||
|
|
||||||
GlobalUnlock(aHGBL);
|
GlobalUnlock(aHGBL);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче