Skip to content

Commit b39ef58

Browse files
Rot127notxvilka
authored andcommitted
Fix segfault if sorted or unsorted lines are empty.
1 parent 85c1b28 commit b39ef58

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

librz/cons/grep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,13 @@ RZ_API void rz_cons_grepbuf(void) {
750750
char *ptr = cons->context->buffer;
751751
char *str;
752752
grep->sorted_column = grep->sort;
753+
if (!grep->sorted_lines || !grep->unsorted_lines) {
754+
rz_list_free(grep->sorted_lines);
755+
rz_list_free(grep->unsorted_lines);
756+
grep->sorted_lines = NULL;
757+
grep->unsorted_lines = NULL;
758+
return;
759+
}
753760
rz_list_sort(grep->sorted_lines, cmp, grep);
754761
if (grep->sort_invert) {
755762
rz_list_reverse(grep->sorted_lines);

0 commit comments

Comments
 (0)