reftable: handle realloc error in parse_names()

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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Dec 28, 2024 at 10:48 UTC e4981ed1e72d3f25da901b9415d2c4805bed0dbc
1 file changed +2 -1
reftable/basics.c
+2 -1
@@ -241,7 +241,8 @@ char **parse_names(char *buf, int size)
241 p = next + 1;
242 }
243
244 - REFTABLE_REALLOC_ARRAY(names, names_len + 1);
244 + if (REFTABLE_ALLOC_GROW(names, names_len + 1, names_cap))
245 + goto err;
246 names[names_len] = NULL;
247
248 return names;