]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable: handle realloc error in parse_names()
authorRené Scharfe <l.s.r@web.de>
Sat, 28 Dec 2024 09:48:50 +0000 (10:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 28 Dec 2024 16:00:44 +0000 (08:00 -0800)
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>
reftable/basics.c

index cd6b39dbe9c8dba619154ff1d11448845399567e..fe2b83ff83b0923a30b585af873b1deca9dbdbc6 100644 (file)
@@ -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;