From 0d227b5019063abf159ecb22b191859f4417edc6 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 10 Jan 2022 17:04:49 +0100 Subject: [PATCH] Fixed reg_unload: ignore empty root_key (cherry picked from commit 327935dfaf1b95de62f6b94704f2adcefacd6b1b) --- winpr/libwinpr/registry/registry_reg.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/winpr/libwinpr/registry/registry_reg.c b/winpr/libwinpr/registry/registry_reg.c index 264cbb351..9fd31a3cc 100644 --- a/winpr/libwinpr/registry/registry_reg.c +++ b/winpr/libwinpr/registry/registry_reg.c @@ -459,17 +459,19 @@ static void reg_unload(Reg* reg) RegKey* pKey; WINPR_ASSERT(reg); - WINPR_ASSERT(reg->root_key); - pKey = reg->root_key->subkeys; - - while (pKey != NULL) + if (reg->root_key) { - RegKey* pKeyNext = pKey->next; - reg_unload_key(reg, pKey); - pKey = pKeyNext; - } + pKey = reg->root_key->subkeys; - free(reg->root_key); + while (pKey != NULL) + { + RegKey* pKeyNext = pKey->next; + reg_unload_key(reg, pKey); + pKey = pKeyNext; + } + + free(reg->root_key); + } } Reg* reg_open(BOOL read_only)