diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-10-02 12:55:38 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-10-02 07:53:51 -0700 |
| commit | eef7bcdafe0037f14a96c564ace899342b9ed0fb (patch) | |
| tree | f22f256d6bed8a3110af520cbb60a79da3f64657 /reftable/stack.c | |
| parent | 6593e147d3992eb52cb53b6f8a09dc3e10f79613 (diff) | |
reftable/basics: handle allocation failures in `parse_names()`
Handle allocation failures in `parse_names()` by returning `NULL` in
case any allocation fails. While at it, refactor the function to return
the array directly instead of assigning it to an out-pointer.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/stack.c')
| -rw-r--r-- | reftable/stack.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/reftable/stack.c b/reftable/stack.c index ce0a35216b..498fae846d 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -108,7 +108,11 @@ static int fd_read_lines(int fd, char ***namesp) } buf[size] = 0; - parse_names(buf, size, namesp); + *namesp = parse_names(buf, size); + if (!*namesp) { + err = REFTABLE_OUT_OF_MEMORY_ERROR; + goto done; + } done: reftable_free(buf); |
