mirror of https://github.com/xzeldon/htop.git
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.
This commit is contained in:
parent
fefff80631
commit
c401ac3a98
5
Action.c
5
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue