mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
repo/commit: Fix memory leak
While running the testsuite under valgrind a small memory leak showed up: ==16487== 65 bytes in 1 blocks are definitely lost in loss record 773 of 1,123 ==16487== at 0x4C2BBAF: malloc (vg_replace_malloc.c:299) ==16487== by 0x6048E08: g_malloc (gmem.c:94) ==16487== by 0x6062EAE: g_strdup (gstrfuncs.c:363) ==16487== by 0x54CE3E6: write_object (ostree-repo-commit.c:776) ==16487== by 0x54CF2D4: ostree_repo_write_metadata (ostree-repo-commit.c:1528) ==16487== by 0x54CF505: _ostree_repo_write_directory_meta (ostree-repo-commit.c:1712) ==16487== by 0x54D0AB4: write_dfd_iter_to_mtree_internal (ostree-repo-commit.c:2650) ==16487== by 0x54D0E2D: ostree_repo_write_dfd_to_mtree (ostree-repo-commit.c:2793) ==16487== by 0x1190C4: ostree_builtin_commit (ot-builtin-commit.c:474) ==16487== by 0x11F2EE: ostree_run (ot-main.c:200) ==16487== by 0x116F32: main (main.c:78) The reason for this is that ot_checksum_instream_get_string returns a chunk of newly allocated memory which never got freed. Make actual_checksum something that gets autocleanend and own the memory assigned to it in all cases. Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Closes: #827 Approved by: pwithnall
This commit is contained in:
parent
712bf21914
commit
e6666fc2e5
@ -607,7 +607,8 @@ write_object (OstreeRepo *self,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *actual_checksum;
|
||||
const char *actual_checksum = NULL;
|
||||
g_autofree char *actual_checksum_owned = NULL;
|
||||
gboolean do_commit;
|
||||
OstreeRepoMode repo_mode;
|
||||
g_autofree char *temp_filename = NULL;
|
||||
@ -772,7 +773,7 @@ write_object (OstreeRepo *self,
|
||||
actual_checksum = expected_checksum;
|
||||
else
|
||||
{
|
||||
actual_checksum = ot_checksum_instream_get_string (checksum_input);
|
||||
actual_checksum = actual_checksum_owned = ot_checksum_instream_get_string (checksum_input);
|
||||
if (expected_checksum && strcmp (actual_checksum, expected_checksum) != 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
|
Loading…
x
Reference in New Issue
Block a user