Skip to content

Commit

Permalink
reftable: handle realloc error in parse_names()
Browse files Browse the repository at this point in the history
Check the final reallocation for adding the terminating NULL and handle
it just like those in the loop.  Simply use REFTABLE_ALLOC_GROW instead
of keeping the REFTABLE_REALLOC_ARRAY call and adding code to preserve
the original pointer value around it.

Signed-off-by: René Scharfe <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
rscharfe authored and gitster committed Dec 28, 2024
1 parent 2cca185 commit e4981ed
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion reftable/basics.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ char **parse_names(char *buf, int size)
p = next + 1;
}

REFTABLE_REALLOC_ARRAY(names, names_len + 1);
if (REFTABLE_ALLOC_GROW(names, names_len + 1, names_cap))
goto err;
names[names_len] = NULL;

return names;
Expand Down

0 comments on commit e4981ed

Please sign in to comment.