[PATCH 0/1] MR1460: hhctrl: Handle memory allocation failure in GetChmString.
From: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/hhctrl.ocx/chm.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c index 3a9a8fa9e7a..d48ceced1a0 100644 --- a/dlls/hhctrl.ocx/chm.c +++ b/dlls/hhctrl.ocx/chm.c @@ -32,18 +32,25 @@ WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); static LPCSTR GetChmString(CHMInfo *chm, DWORD offset) { LPCSTR str; + const char **new_strings; if(!chm->strings_stream) return NULL; - if(chm->strings_size <= (offset >> BLOCK_BITS)) { + if(chm->strings_size <=(offset >> BLOCK_BITS)) { chm->strings_size = (offset >> BLOCK_BITS)+1; - if(chm->strings) - chm->strings = heap_realloc_zero(chm->strings, + if(chm->strings) { + new_strings = heap_realloc_zero(chm->strings, chm->strings_size*sizeof(char*)); - else + if(!new_strings) + return NULL; + chm->strings = new_strings; + }else { chm->strings = heap_alloc_zero( chm->strings_size*sizeof(char*)); + if(!chm->strings) + return NULL; + } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1460
participants (2)
-
Alex Henrie -
Alex Henrie (@alexhenrie)