]> granicus.if.org Git - git/commitdiff
contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing
authorBrandon Casey <drafnel@gmail.com>
Mon, 23 Sep 2013 18:49:08 +0000 (11:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Oct 2013 16:35:31 +0000 (09:35 -0700)
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>
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c

index b9bb794601784f9eb06afa26ded0e5efffba8d8e..0d2c55e0d22a1e1dd88f48f67e6c63ccaf652191 100644 (file)
@@ -314,7 +314,7 @@ static int credential_read(struct credential *c)
        {
                line_len = strlen(buf);
 
-               if (buf[line_len-1]=='\n')
+               if (line_len && buf[line_len-1] == '\n')
                        buf[--line_len]='\0';
 
                if (!line_len)