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 2013-09-23 11:49:08 -07:00 committed by Junio C Hamano
parent fb2763746f
commit 73bbc0796b
1 changed files with 1 additions and 1 deletions

View 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)