mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Always check the return value of repo_read_object_file()
There are a couple of places in Git's source code where the return value is not checked. As a consequence, they are susceptible to segmentation faults. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
564d0252ca
commit
568459bf5e
@@ -718,9 +718,11 @@ static int append_edit(int argc, const char **argv, const char *prefix)
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
char *prev_buf = repo_read_object_file(the_repository, note, &type, &size);
|
||||
|
||||
if (prev_buf && size)
|
||||
if (!prev_buf)
|
||||
die(_("unable to read %s"), oid_to_hex(note));
|
||||
if (size)
|
||||
strbuf_add(&buf, prev_buf, size);
|
||||
if (d.buf.len && prev_buf && size)
|
||||
if (d.buf.len && size)
|
||||
append_separator(&buf);
|
||||
strbuf_insert(&d.buf, 0, buf.buf, buf.len);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user