From 59ef15b2ad6037f40d7fe4207b2b59dd11b14b8b Mon Sep 17 00:00:00 2001 From: Erdem Ersoy Date: Fri, 30 Oct 2020 19:12:17 +0300 Subject: Fix segmentation fault when column name is NULL. So, some columns (ex: SECATTR) can be sortable now. --- htop.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'htop.c') 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); -- cgit v1.2.3