contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing
Ensure buffer length is non-zero before attempting to access the last element. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Sep 23, 2013 at 11:49 UTC
73bbc0796b4ce65bfb1a12b47a0edc27845ecf50
1 file changed
+1
-1
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+1
-1
@@ -314,7 +314,7 @@ static int credential_read(struct credential *c)
314
{
315
line_len = strlen(buf);
316
317
- if (buf[line_len-1]=='\n')
317
+ if (line_len && buf[line_len-1] == '\n')
318
buf[--line_len]='\0';
319
320
if (!line_len)