Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-10-03 17:36:40 +0300
committerJunio C Hamano <gitster@pobox.com>2017-10-04 07:41:49 +0300
commit97487ea11a2c68934927e515616c133e543a72ce (patch)
treed10311cf0a99e338d4a43f8bd67e524fc81ee148 /t/helper/test-string-list.c
parent83fc4d64fec779d73b18494461613ef911236daf (diff)
test-stringlist: avoid buffer underrun when sorting nothing
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>
Diffstat (limited to 't/helper/test-string-list.c')
-rw-r--r--t/helper/test-string-list.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c
index c502fa16d3..829ec3d7d2 100644
--- 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);