From: Brandon Casey Date: Mon, 23 Sep 2013 18:49:08 +0000 (-0700) Subject: contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing X-Git-Tag: v1.8.5-rc0~28^2~9 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/73bbc0796b4ce65bfb1a12b47a0edc27845ecf50 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 Signed-off-by: Junio C Hamano --- diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c index b9bb794601..0d2c55e0d2 100644 --- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c +++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.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)