diff options
author | Erdem Ersoy <erdemersoy@erdemersoy.net> | 2020-10-30 19:12:17 +0300 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2020-10-31 18:34:34 +0100 |
commit | 59ef15b2ad6037f40d7fe4207b2b59dd11b14b8b (patch) | |
tree | 20785b9da09c3f969b71f21bb96391b2882fa5cb /htop.c | |
parent | 6787c430977974c08eab6f3f15bb9a876aa415fa (diff) |
Fix segmentation fault when column name is NULL.
So, some columns (ex: SECATTR) can be sortable now.
Diffstat (limited to 'htop.c')
-rw-r--r-- | htop.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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); |