Squashed 'external/toxcore/c-toxcore/' changes from 75f3c33943..d4b06edc2a

d4b06edc2a feat: add ngc events
cd34b60f0f feat: allow for larger incoming NGC packets
94cf9d1f36 fix: Fix memory leak in the error path of loading savedata.
fc623a5281 tox_new() should return null when savedata loading fails
06d949a701 fix: always respond to version packets with toxcore version
REVERT: 75f3c33943 adopt to #2415 changes
REVERT: 38e4c82fe0 feat: add ngc events

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: d4b06edc2a35bad51b0f0950d74f61c8c70630ab
This commit is contained in:
2023-11-17 16:01:52 +01:00
parent cdc4284cb5
commit 4f02c2b55b
8 changed files with 55 additions and 21 deletions

View File

@ -858,12 +858,26 @@ 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);
if (tox->mutex != nullptr) {
pthread_mutex_destroy(tox->mutex);
}
mem_delete(sys->mem, tox->mutex);
mem_delete(sys->mem, tox);
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT);
} else if (load_savedata_sk) {
return nullptr;
}
if (load_savedata_sk) {
load_secret_key(tox->m->net_crypto, tox_options_get_savedata_data(opts));
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
} else {
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
}
m_callback_namechange(tox->m, tox_friend_name_handler);
@ -913,6 +927,9 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
tox_options_free(default_options);
tox_unlock(tox);
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
return tox;
}