Skip to content

Commit e4981ed

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2cca185 commit e4981ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

reftable/basics.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ char **parse_names(char *buf, int size)
241241
p = next + 1;
242242
}
243243

244-
REFTABLE_REALLOC_ARRAY(names, names_len + 1);
244+
if (REFTABLE_ALLOC_GROW(names, names_len + 1, names_cap))
245+
goto err;
245246
names[names_len] = NULL;
246247

247248
return names;

0 commit comments

Comments
 (0)