Browse Source

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>
maint
Brandon Casey 11 years ago committed by Junio C Hamano
parent
commit
73bbc0796b
  1. 2
      contrib/credential/gnome-keyring/git-credential-gnome-keyring.c

2
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c

@ -314,7 +314,7 @@ static int credential_read(struct credential *c) @@ -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)

Loading…
Cancel
Save