Skip to content

Commit

Permalink
fix: Fix memory leak in the error path of loading savedata.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Nov 16, 2023
1 parent fc623a5 commit 94cf9d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8942735f04e41962bbcfaeccbfa6487424ad78c910e932d93b5b6f56a6e852b7 /usr/local/bin/tox-bootstrapd
a5b7485734edb8ce54146f95391d7e14ea9cce4dbc92ded64230e1933a3371e8 /usr/local/bin/tox-bootstrapd
7 changes: 5 additions & 2 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)

if (load_savedata_tox
&& tox_load(tox, tox_options_get_savedata_data(opts), tox_options_get_savedata_length(opts)) == -1) {
kill_groupchats(tox->m->conferences_object);
kill_messenger(tox->m);

mono_time_free(tox->sys.mem, tox->mono_time);
tox_options_free(default_options);
tox_unlock(tox);
Expand All @@ -866,8 +869,8 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
pthread_mutex_destroy(tox->mutex);
}

free(tox->mutex);
free(tox);
mem_delete(sys->mem, tox->mutex);
mem_delete(sys->mem, tox);

SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT);
return nullptr;
Expand Down

0 comments on commit 94cf9d1

Please sign in to comment.