Skip to content

Commit 73bbc07

Browse files
drafnelgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb27637 commit 73bbc07

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static int credential_read(struct credential *c)
314314
{
315315
line_len = strlen(buf);
316316

317-
if (buf[line_len-1]=='\n')
317+
if (line_len && buf[line_len-1] == '\n')
318318
buf[--line_len]='\0';
319319

320320
if (!line_len)

0 commit comments

Comments
 (0)