pack-write.c: plug a leak in stage_tmp_packfiles()
commitc41258359e2f77a4fba000b2bbb975ebaf7d641b
authorTaylor Blau <me@ttaylorr.com>
Tue, 18 Apr 2023 20:40:32 +0000 (18 16:40 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Apr 2023 21:56:47 +0000 (18 14:56 -0700)
treeb42af0fd14f33a60475b607988119656c3672e04
parent9857273be005833c71e2d16ba48e193113e12276
pack-write.c: plug a leak in stage_tmp_packfiles()

The function `stage_tmp_packfiles()` generates a filename to use for
staging the contents of what will become the pack's ".mtimes" file.

The name is generated in `write_mtimes_file()` and the result is
returned back to `stage_tmp_packfiles()` which uses it to rename the
temporary file into place via `rename_tmp_packfiles()`.

`write_mtimes_file()` returns a `const char *`, indicating that callers
are not expected to free its result (similar to, e.g., `oid_to_hex()`).
But callers are expected to free its result, so this return type is
incorrect.

Change the function's signature to return a non-const `char *`, and free
it at the end of `stage_tmp_packfiles()`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-write.c