[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dynamic-complete-history: avoid null ptr qsort UB
From: |
Grisha Levit |
Subject: |
[PATCH] dynamic-complete-history: avoid null ptr qsort UB |
Date: |
Tue, 21 May 2024 23:58:48 -0400 |
$ HISTFILE= bash --norc -in <<< $'#\n#\e\t'
bashline.c:3720:16: runtime error: null pointer passed as argument 1, which is
declared to never be null
/usr/include/stdlib.h:971:30: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior bashline.c:3720:16
---
bashline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bashline.c b/bashline.c
index 0a4e280e..1f234122 100644
--- a/bashline.c
+++ b/bashline.c
@@ -3727,7 +3727,7 @@ build_history_completion_array (void)
}
/* Sort the complete list of tokens. */
- if (dabbrev_expand_active == 0)
+ if (harry_len && dabbrev_expand_active == 0)
qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC
*)strvec_strcmp);
}
}
--
2.45.1
- [PATCH] dynamic-complete-history: avoid null ptr qsort UB,
Grisha Levit <=