From 9ea2222967054bc086d6cf5f2b75935b13f2d60e Mon Sep 17 00:00:00 2001 From: Thamatip Chitpong Date: Sun, 3 Dec 2023 08:15:08 +0700 Subject: [PATCH] [HH] Check LoadLibrary and GetProcAddress return value (#6082) Handle failure cases. --- base/applications/hh/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/base/applications/hh/main.c b/base/applications/hh/main.c index 3d06156167b..beb2882ee4e 100644 --- a/base/applications/hh/main.c +++ b/base/applications/hh/main.c @@ -15,11 +15,14 @@ WinMain(HINSTANCE hInst, int ret = -1; hModule = LoadLibraryA("hhctrl.ocx"); - doWinMain = (DOWINMAIN*) GetProcAddress(hModule, "doWinMain"); + if (hModule) + { + doWinMain = (DOWINMAIN*)GetProcAddress(hModule, "doWinMain"); + if (doWinMain) + ret = doWinMain(hInst, cmdline); - ret = doWinMain(hInst, cmdline); - - FreeLibrary(hModule); + FreeLibrary(hModule); + } return ret; }