From 8c160d2c7a17eb842fae82de3638b834976f2aa2 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Thu, 20 Aug 2020 16:42:54 +0200 Subject: [PATCH] NVDynamic: Fix use of uninitialized value. There is a theoretical possibility that the cycle in NvNextByType does not run at all because NvNext fails immediately and never sets nvHandle. The cycle only runs and nvHandle is set on non-zero addr, and in that case addr remains non-zero when breaking out of the cycle. Use nvHandle only when addr is non-zero. Signed-off-by: Michal Suchanek --- src/NVDynamic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NVDynamic.c b/src/NVDynamic.c index 8ede9e4..535ea03 100644 --- a/src/NVDynamic.c +++ b/src/NVDynamic.c @@ -122,7 +122,7 @@ NvNextByType( if(HandleGetType(nvHandle) == type) break; } - if(handle != NULL) + if(addr && (handle != NULL)) *handle = nvHandle; return addr; } -- 2.42.0