Silence possible NULL dereference

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]
This commit is contained in:
Christian Göttsche 2020-12-03 12:32:54 +01:00
parent fe84840314
commit 3695cbd5d8
1 changed files with 2 additions and 1 deletions

View File

@ -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);