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)