summaryrefslogtreecommitdiffstats
path: root/reftable
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2024-12-28 10:48:50 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-28 17:00:44 +0100
commite4981ed1e72d3f25da901b9415d2c4805bed0dbc (patch)
treebfd4661fe27c1992f25113b315ec427f296133b6 /reftable
parentreftable: fix allocation count on realloc error (diff)
downloadgit-e4981ed1e72d3f25da901b9415d2c4805bed0dbc.tar.xz
git-e4981ed1e72d3f25da901b9415d2c4805bed0dbc.zip
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>
Diffstat (limited to 'reftable')
-rw-r--r--reftable/basics.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/reftable/basics.c b/reftable/basics.c
index cd6b39dbe9..fe2b83ff83 100644
--- a/reftable/basics.c
+++ b/reftable/basics.c
@@ -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;