Merge branch 'js/check-null-from-read-object-file'

The code paths that call repo_read_object_file() have been
tightened to react to errors.

* js/check-null-from-read-object-file:
  Always check the return value of `repo_read_object_file()`
This commit is contained in:
Junio C Hamano
2024-02-14 15:36:06 -08:00
6 changed files with 22 additions and 4 deletions

View File

@ -716,9 +716,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);