Fixed some OOM conditions in GlobalAlloc.

This commit is contained in:
Eric Pouech 2000-06-24 12:51:24 +00:00 committed by Alexandre Julliard
parent e384fa6b6d
commit 3bcfb90188
1 changed files with 5 additions and 1 deletions

View File

@ -1039,9 +1039,13 @@ HGLOBAL WINAPI GlobalAlloc(
/* HeapLock(heap); */
pintern=HeapAlloc(heap, 0, sizeof(GLOBAL32_INTERN));
if (!pintern) return NULL;
if(size)
{
palloc=HeapAlloc(heap, hpflags, size+sizeof(HGLOBAL));
if (!(palloc=HeapAlloc(heap, hpflags, size+sizeof(HGLOBAL)))) {
HeapFree(heap, 0, pintern);
return NULL;
}
*(HGLOBAL *)palloc=INTERN_TO_HANDLE(pintern);
pintern->Pointer=(char *) palloc+sizeof(HGLOBAL);
}