summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-08-17 14:38:19 +1000
committerNathan Scott <nathans@redhat.com>2021-08-17 14:41:40 +1000
commitc401ac3a98563f84e1957445f4c5643186e0e9d3 (patch)
tree1f43c17ad890b1da80544473ea1b6ba9839f4bf3
parentfefff80631e86f0296a2621a3699b16de60b86c6 (diff)
Ensure DynamicColumn hash lookups never see NULL pointers
This cannot happen in these code locations, but for the purposes of static checkers like Coverity scan (and for future proofing), add two more guards on NULL hash table entry pointers.
-rw-r--r--Action.c5
-rw-r--r--pcp/PCPDynamicColumn.c3
2 files changed, 6 insertions, 2 deletions
diff --git a/Action.c b/Action.c
index 5d774587..6e804f68 100644
--- a/Action.c
+++ b/Action.c
@@ -174,8 +174,9 @@ static Htop_Reaction actionSetSortColumn(State* st) {
char* name = NULL;
if (fields[i] >= LAST_PROCESSFIELD) {
DynamicColumn* column = Hashtable_get(dynamicColumns, fields[i]);
- if (column)
- name = xStrdup(column->caption ? column->caption : column->name);
+ if (column == NULL)
+ continue;
+ name = xStrdup(column->caption ? column->caption : column->name);
} else {
name = String_trim(Process_fields[fields[i]].name);
}
diff --git a/pcp/PCPDynamicColumn.c b/pcp/PCPDynamicColumn.c
index 141978a7..4051e101 100644
--- a/pcp/PCPDynamicColumn.c
+++ b/pcp/PCPDynamicColumn.c
@@ -287,6 +287,9 @@ void PCPDynamicColumn_writeField(PCPDynamicColumn* this, const Process* proc, Ri
int PCPDynamicColumn_compareByKey(const PCPProcess* p1, const PCPProcess* p2, ProcessField key) {
const PCPDynamicColumn* column = Hashtable_get(p1->super.processList->dynamicColumns, key);
+ if (column == NULL)
+ return -1;
+
size_t metric = column->id;
unsigned int type = PCPMetric_type(metric);

© 2014-2024 Faster IT GmbH | imprint | privacy policy