Skip to content

Commit 94cf9d1

Browse files
committed
fix: Fix memory leak in the error path of loading savedata.
1 parent fc623a5 commit 94cf9d1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8942735f04e41962bbcfaeccbfa6487424ad78c910e932d93b5b6f56a6e852b7 /usr/local/bin/tox-bootstrapd
1+
a5b7485734edb8ce54146f95391d7e14ea9cce4dbc92ded64230e1933a3371e8 /usr/local/bin/tox-bootstrapd

toxcore/tox.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,9 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
858858

859859
if (load_savedata_tox
860860
&& tox_load(tox, tox_options_get_savedata_data(opts), tox_options_get_savedata_length(opts)) == -1) {
861+
kill_groupchats(tox->m->conferences_object);
862+
kill_messenger(tox->m);
863+
861864
mono_time_free(tox->sys.mem, tox->mono_time);
862865
tox_options_free(default_options);
863866
tox_unlock(tox);
@@ -866,8 +869,8 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
866869
pthread_mutex_destroy(tox->mutex);
867870
}
868871

869-
free(tox->mutex);
870-
free(tox);
872+
mem_delete(sys->mem, tox->mutex);
873+
mem_delete(sys->mem, tox);
871874

872875
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT);
873876
return nullptr;

0 commit comments

Comments
 (0)