diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c index 30481d85e07..348090e0c03 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/lolvldrv.c @@ -564,9 +564,15 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) part->nIDMin, part->nIDMax, llTypes[type].wMaxId, lpDrv->drvname, llTypes[type].typestr); /* realloc translation table */ - llTypes[type].lpMlds = (LPWINE_MLD) - HeapReAlloc(GetProcessHeap(), 0, (llTypes[type].lpMlds) ? llTypes[type].lpMlds - 1 : NULL, + if (llTypes[type].lpMlds) + llTypes[type].lpMlds = (LPWINE_MLD) + HeapReAlloc(GetProcessHeap(), 0, llTypes[type].lpMlds - 1, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1; + else + llTypes[type].lpMlds = (LPWINE_MLD) + HeapAlloc(GetProcessHeap(), 0, + sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1; + /* re-build the translation table */ if (llTypes[type].nMapper != -1) { TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname); diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c index 85c06f8d499..2034edb94b9 100644 --- a/dlls/winmm/time.c +++ b/dlls/winmm/time.c @@ -126,10 +126,15 @@ static void CALLBACK TIME_MMSysTimeCallback(LPWINE_MM_IDATA iData) lpTimer->uCurTime += lpTimer->wDelay - MMSYSTIME_MININTERVAL; if (lpTimer->lpFunc) { if (idx == iData->nSizeLpTimers) { - iData->lpTimers = (LPWINE_TIMERENTRY) + if (iData->lpTimers) + iData->lpTimers = (LPWINE_TIMERENTRY) HeapReAlloc(GetProcessHeap(), 0, iData->lpTimers, ++iData->nSizeLpTimers * sizeof(WINE_TIMERENTRY)); + else + iData->lpTimers = (LPWINE_TIMERENTRY) + HeapAlloc(GetProcessHeap(), 0, + ++iData->nSizeLpTimers * sizeof(WINE_TIMERENTRY)); } iData->lpTimers[idx++] = *lpTimer; } diff --git a/dlls/winmm/winejack/audio.c b/dlls/winmm/winejack/audio.c index 9488f59eea3..5c12951775e 100644 --- a/dlls/winmm/winejack/audio.c +++ b/dlls/winmm/winejack/audio.c @@ -450,7 +450,11 @@ int JACK_bufsize (nframes_t nframes, void *arg) wwo->buffer_size, buffer_required); TRACE("GetProcessHeap() == %p\n", GetProcessHeap()); wwo->buffer_size = buffer_required; - wwo->sound_buffer = HeapReAlloc(GetProcessHeap(), 0, wwo->sound_buffer, wwo->buffer_size); + + if (wwo->sound_buffer) + wwo->sound_buffer = HeapReAlloc(GetProcessHeap(), 0, wwo->sound_buffer, wwo->buffer_size); + else + wwo->sound_buffer = HeapAlloc(GetProcessHeap(), 0, wwo->buffer_size); /* if we don't have a buffer then error out */ if(!wwo->sound_buffer) diff --git a/dlls/winmm/wineoss/audio.c b/dlls/winmm/wineoss/audio.c index e109a5b6ec2..93dc2aa85ea 100644 --- a/dlls/winmm/wineoss/audio.c +++ b/dlls/winmm/wineoss/audio.c @@ -3341,8 +3341,13 @@ static HRESULT WINAPI IDsDriverNotifyImpl_SetNotificationPositions( /* Make an internal copy of the caller-supplied array. * Replace the existing copy if one is already present. */ - This->notifies = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - This->notifies, howmuch * sizeof(DSBPOSITIONNOTIFY)); + if (This->notifies) + This->notifies = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + This->notifies, howmuch * sizeof(DSBPOSITIONNOTIFY)); + else + This->notifies = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + howmuch * sizeof(DSBPOSITIONNOTIFY)); + memcpy(This->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY)); This->nrofnotifies = howmuch; diff --git a/dlls/winspool/info.c b/dlls/winspool/info.c index 733e6ba877b..7aafd7e77e5 100644 --- a/dlls/winspool/info.c +++ b/dlls/winspool/info.c @@ -430,8 +430,14 @@ static HANDLE WINSPOOL_GetOpenedPrinterEntry( LPCWSTR name ) if (i >= nb_printers) { - LPWSTR *new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, printer_array, + LPWSTR *new_array; + if (printer_array) + new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, printer_array, (nb_printers + 16) * sizeof(*new_array) ); + else + new_array = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + (nb_printers + 16) * sizeof(*new_array) ); + if (!new_array) return 0; printer_array = new_array; nb_printers += 16; diff --git a/graphics/x11drv/palette.c b/graphics/x11drv/palette.c index e0141935e57..6469d3ca76e 100644 --- a/graphics/x11drv/palette.c +++ b/graphics/x11drv/palette.c @@ -1062,9 +1062,13 @@ static UINT X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNu X11DRV_PALETTE_FormatSystemPalette(); /* initialize palette mapping table */ - - mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping, + if (palPtr->mapping) + mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping, sizeof(int)*palPtr->logpalette.palNumEntries); + else + mapping = HeapAlloc( GetProcessHeap(), 0, + sizeof(int)*palPtr->logpalette.palNumEntries); + if(mapping == NULL) { ERR("Can not allocate new mapping -- memory exausted!\n"); return 0; diff --git a/programs/wineconsole/curses.c b/programs/wineconsole/curses.c index cdd0bb34ea0..c5e365c75cf 100644 --- a/programs/wineconsole/curses.c +++ b/programs/wineconsole/curses.c @@ -223,7 +223,11 @@ static void WCCURSES_ResizeScreenBuffer(struct inner_data* data) PRIVATE(data)->pad = newpad(data->curcfg.sb_height, data->curcfg.sb_width); if (!PRIVATE(data)->pad) WINE_FIXME("Cannot create pad\n"); - PRIVATE(data)->line = HeapReAlloc(GetProcessHeap(), 0, PRIVATE(data)->line, + if (PRIVATE(data)->line) + PRIVATE(data)->line = HeapReAlloc(GetProcessHeap(), 0, PRIVATE(data)->line, + sizeof(chtype) * data->curcfg.sb_width); + else + PRIVATE(data)->line = HeapAlloc(GetProcessHeap(), 0, sizeof(chtype) * data->curcfg.sb_width); } diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 4ad57f15dd3..0cd1ec1b9c8 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -291,8 +291,13 @@ int WINECON_GrabChanges(struct inner_data* data) data->curcfg.sb_width = evts[i].u.resize.width; data->curcfg.sb_height = evts[i].u.resize.height; - data->cells = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data->cells, + if (data->cells) + data->cells = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data->cells, data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO)); + else + data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO)); + if (!data->cells) WINECON_Fatal("OOM\n"); data->fnResizeScreenBuffer(data); data->fnComputePositions(data); diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c index 8647e77650f..3345893b134 100644 --- a/programs/winhelp/hlpfile.c +++ b/programs/winhelp/hlpfile.c @@ -776,8 +776,13 @@ static BOOL HLPFILE_LoadGfxByIndex(HLPFILE *hlpfile, unsigned index, if (index >= hlpfile->numBmps) { hlpfile->numBmps = index + 1; - hlpfile->bmps = HeapReAlloc(GetProcessHeap(), 0, hlpfile->bmps, + if (hlpfile->bmps) + hlpfile->bmps = HeapReAlloc(GetProcessHeap(), 0, hlpfile->bmps, hlpfile->numBmps * sizeof(hlpfile->bmps[0])); + else + hlpfile->bmps = HeapAlloc(GetProcessHeap(), 0, + hlpfile->numBmps * sizeof(hlpfile->bmps[0])); + } hlpfile->bmps[index] = paragraph->u.gfx.u.bmp.hBitmap; } @@ -1395,8 +1400,14 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile) case 6: if (GET_USHORT(ptr, 2) != 90) {WINE_WARN("system6\n");break;} - hlpfile->windows = HeapReAlloc(GetProcessHeap(), 0, hlpfile->windows, + + if (hlpfile->windows) + hlpfile->windows = HeapReAlloc(GetProcessHeap(), 0, hlpfile->windows, sizeof(HLPFILE_WINDOWINFO) * ++hlpfile->numWindows); + else + hlpfile->windows = HeapAlloc(GetProcessHeap(), 0, + sizeof(HLPFILE_WINDOWINFO) * ++hlpfile->numWindows); + if (hlpfile->windows) { unsigned flags = GET_USHORT(ptr, 4);