Skip to content

Commit

Permalink
contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty be…
Browse files Browse the repository at this point in the history
…fore 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>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed Oct 16, 2013
1 parent fb27637 commit 73bbc07
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 73bbc07

Please sign in to comment.