Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
test-stringlist: avoid buffer underrun when sorting nothing
author
René Scharfe
<l.s.r@web.de>
Tue, 3 Oct 2017 14:36:40 +0000
(16:36 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 4 Oct 2017 04:41:49 +0000
(13:41 +0900)
Check if the strbuf containing data to sort is empty before attempting
to trim a trailing newline character.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-string-list.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
83fc4d6
)
diff --git
a/t/helper/test-string-list.c
b/t/helper/test-string-list.c
index c502fa16d307957b6fe23cbd5481fc35f49c00da..829ec3d7d2f58b9538bb3bbab47213eddb9e62ec 100644
(file)
--- a/
t/helper/test-string-list.c
+++ b/
t/helper/test-string-list.c
@@
-108,7
+108,7
@@
int cmd_main(int argc, const char **argv)
* Split by newline, but don't create a string_list item
* for the empty string after the last separator.
*/
- if (sb.buf[sb.len - 1] == '\n')
+ if (sb.
len && sb.
buf[sb.len - 1] == '\n')
strbuf_setlen(&sb, sb.len - 1);
string_list_split_in_place(&list, sb.buf, '\n', -1);