]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-file: fix leak on conversion failure
authorEric Wong <e@80x24.org>
Sat, 22 Jun 2024 04:36:48 +0000 (04:36 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Jun 2024 16:07:21 +0000 (09:07 -0700)
I'm not sure exactly how to trigger the leak, but it seems fairly
obvious that the `content' buffer should be freed even if
convert_object_file() fails.  Noticed while working in this area
on unrelated things.

Signed-off-by: Eric Wong <e@80x24.org>
Acked-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c

index 610b1f465c4248e8c0520687049a707a8497195e..dd441627d6b10ac1e8ec545e653b7ab6c2d8c26f 100644 (file)
@@ -1711,9 +1711,9 @@ static int oid_object_info_convert(struct repository *r,
                        ret = convert_object_file(&outbuf,
                                                  the_hash_algo, input_algo,
                                                  content, size, type, !do_die);
+                       free(content);
                        if (ret == -1)
                                return -1;
-                       free(content);
                        size = outbuf.len;
                        content = strbuf_detach(&outbuf, NULL);
                }