From: René Scharfe Date: Wed, 25 Dec 2024 18:38:40 GMT Subject: [PATCH 3/4] reftable: handle realloc error in parse_names() Message-ID: <3ca514b7-63f8-49cb-9816-627d706c6145@web.de> In-Reply-To: <2b9fba8d-be63-4145-9d25-a2151e422cfa@web.de> 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 --- reftable/basics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.47.1