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>
This commit is contained in:

committed by
Junio C Hamano

parent
6593e147d3
commit
eef7bcdafe
@ -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);
|
||||
|
Reference in New Issue
Block a user