Module: wine Branch: master Commit: f41214edaabc35a1b774c12345fac3a4136085e1 URL: https://gitlab.winehq.org/wine/wine/-/commit/f41214edaabc35a1b774c12345fac3a...
Author: Alex Henrie alexhenrie24@gmail.com Date: Mon Nov 21 19:17:52 2022 -0700
hhctrl: Handle memory allocation failure in GetChmString.
---
dlls/hhctrl.ocx/chm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c index 3a9a8fa9e7a..aa04a05fa33 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; + char **new_strings;
if(!chm->strings_stream) return NULL;
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; + }
}