{"thread":{"id":"46890","subject":"[PATCH] test-stringlist: avoid buffer underrun when sorting nothing","startedAt":"2017-10-03T14:36:51Z","lastAt":"2017-10-03T22:59:28Z","messageCount":2,"participants":["René Scharfe","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"329574","messageId":"16d3a84c-b695-a55d-0263-885d0d34ae95@web.de","threadId":"46890","inReplyTo":null,"subject":"[PATCH] test-stringlist: avoid buffer underrun when sorting nothing","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-10-03T14:36:40Z","receivedAt":"2017-10-03T14:36:51Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Check if the strbuf containing data to sort is empty before attempting\nto trim a trailing newline character.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n t/helper/test-string-list.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c\nindex c502fa16d3..829ec3d7d2 100644\n--- a/t/helper/test-string-list.c\n+++ b/t/helper/test-string-list.c\n@@ -108,7 +108,7 @@ int cmd_main(int argc, const char **argv)\n \t\t * Split by newline, but don't create a string_list item\n \t\t * for the empty string after the last separator.\n \t\t */\n-\t\tif (sb.buf[sb.len - 1] == '\\n')\n+\t\tif (sb.len && sb.buf[sb.len - 1] == '\\n')\n \t\t\tstrbuf_setlen(&sb, sb.len - 1);\n \t\tstring_list_split_in_place(&list, sb.buf, '\\n', -1);\n \n-- \n2.14.2\n"},{"id":"329616","messageId":"20171003225919.GF19555@aiede.mtv.corp.google.com","threadId":"46890","inReplyTo":"16d3a84c-b695-a55d-0263-885d0d34ae95@web.de","subject":"Re: [PATCH] test-stringlist: avoid buffer underrun when sorting nothing","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-10-03T22:59:19Z","receivedAt":"2017-10-03T22:59:28Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"René Scharfe wrote:\n\n> Check if the strbuf containing data to sort is empty before attempting\n> to trim a trailing newline character.\n>\n> Signed-off-by: Rene Scharfe <l.s.r@web.de>\n> ---\n>  t/helper/test-string-list.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n\nThanks for fixing it.\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n"}]}