Skip to content

Commit

Permalink
Fix segfault if sorted or unsorted lines are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Feb 21, 2025
1 parent 6cf7b82 commit 4d49f17
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions librz/cons/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,13 @@ RZ_API void rz_cons_grepbuf(void) {
char *ptr = cons->context->buffer;
char *str;
grep->sorted_column = grep->sort;
if (!grep->sorted_lines || !grep->unsorted_lines) {
rz_list_free(grep->sorted_lines);
rz_list_free(grep->unsorted_lines);
grep->sorted_lines = NULL;
grep->unsorted_lines = NULL;
return;
}
rz_list_sort(grep->sorted_lines, cmp, grep);
if (grep->sort_invert) {
rz_list_reverse(grep->sorted_lines);
Expand Down

0 comments on commit 4d49f17

Please sign in to comment.