mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Fix segmentation fault when column name is NULL.
So, some columns (ex: SECATTR) can be sortable now.
This commit is contained in:

committed by
Christian Göttsche

parent
6787c43097
commit
59ef15b2ad
10
htop.c
10
htop.c
@ -129,7 +129,15 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
flags.sortKey = ColumnsPanel_fieldNameToIndex(optarg);
|
||||
flags.sortKey = -1;
|
||||
for (int j = 1; j < Platform_numberOfFields; j++) {
|
||||
if (Process_fields[j].name == NULL)
|
||||
continue;
|
||||
if (String_eq(optarg, Process_fields[j].name)) {
|
||||
flags.sortKey = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flags.sortKey == -1) {
|
||||
fprintf(stderr, "Error: invalid column \"%s\".\n", optarg);
|
||||
exit(1);
|
||||
|
Reference in New Issue
Block a user