summaryrefslogtreecommitdiffstats
path: root/htop.c
diff options
context:
space:
mode:
authorErdem Ersoy <erdemersoy@erdemersoy.net>2020-10-30 19:12:17 +0300
committerChristian Göttsche <cgzones@googlemail.com>2020-10-31 18:34:34 +0100
commit59ef15b2ad6037f40d7fe4207b2b59dd11b14b8b (patch)
tree20785b9da09c3f969b71f21bb96391b2882fa5cb /htop.c
parent6787c430977974c08eab6f3f15bb9a876aa415fa (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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/htop.c b/htop.c
index e4d437b9..e02f388a 100644
--- a/htop.c
+++ b/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);

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