]> git.ipfire.org Git - thirdparty/git.git/commit
bundle-uri: plug leak in unbundle_from_file()
authorToon Claes <toon@iotcl.com>
Thu, 10 Oct 2024 09:12:49 +0000 (11:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Oct 2024 18:47:24 +0000 (11:47 -0700)
commit6dab49b9fbbb63a5f58a3cc6e2295f01b1f628f0
treefe3f2f687b2983dd0290d1cadd3e5ededd5dfe22
parent777489f9e09c8d0dd6b12f9d90de6376330577a2
bundle-uri: plug leak in unbundle_from_file()

The function `unbundle_from_file()` has two memory leaks:

  - We do not release the `struct bundle_header header` when hitting
    errors because we return early without any cleanup.

  - We do not release the `struct strbuf bundle_ref` at all.

Plug these leaks by creating a common exit path where both of these
variables are released.

While at it, refactor the code such that the variable assignments do not
happen inside the conditional statement itself according to our coding
style.

Signed-off-by: Toon Claes <toon@iotcl.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bundle-uri.c