From 3695cbd5d8dda27f99383437035450814463b633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 3 Dec 2020 12:32:54 +0100 Subject: [PATCH] Silence possible NULL dereference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by compiling with LTO ProcessList.c: In function ‘ProcessList_updateTreeSetLayer’: ProcessList.c:195:15: error: potential null pointer dereference [-Werror=null-dereference] 195 | if (proc->tree_depth == deep && proc->tree_left > left && proc->tree_right < right) { | ^ ProcessList.c:195:15: error: potential null pointer dereference [-Werror=null-dereference] ProcessList.c:195:15: error: potential null pointer dereference [-Werror=null-dereference] --- ProcessList.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ProcessList.c b/ProcessList.c index 59a7c387..fb4ba481 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -192,7 +192,8 @@ static void ProcessList_updateTreeSetLayer(ProcessList* this, unsigned int leftB // 4 | 6 | 7 for (unsigned int i = leftBound; i < rightBound; i++) { Process* proc = (Process*)Hashtable_get(this->displayTreeSet, i); - if (proc->tree_depth == deep && proc->tree_left > left && proc->tree_right < right) { + assert(proc); + if (proc && proc->tree_depth == deep && proc->tree_left > left && proc->tree_right < right) { if (Vector_size(layer) > 0) { Process* previous_process = (Process*)Vector_get(layer, Vector_size(layer) - 1);