mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-13 02:03:03 +01:00
fix segfault and memory leak
This commit is contained in:
parent
3b7e161149
commit
08f57de9e0
@ -106,7 +106,6 @@ static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, uint8_t *
|
||||
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
uint16_t n_len = tox_get_name(m, num, nick);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
@ -217,6 +216,7 @@ static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, u
|
||||
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
uint16_t n_len = tox_get_name(m, num, nick);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t msg[MAX_STR_SIZE];
|
||||
@ -239,6 +239,7 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, uint8
|
||||
} else {
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
uint16_t n_len = tox_get_name(m, num, nick);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t msg[MAX_STR_SIZE];
|
||||
|
@ -58,9 +58,11 @@ int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum)
|
||||
groupchats[i].peer_names = malloc(sizeof(uint8_t) * TOX_MAX_NAME_LENGTH);
|
||||
groupchats[i].oldpeer_names = malloc(sizeof(uint8_t) * TOX_MAX_NAME_LENGTH);
|
||||
groupchats[i].peer_name_lengths = malloc(sizeof(uint16_t));
|
||||
groupchats[i].oldpeer_name_lengths = malloc(sizeof(uint16_t));
|
||||
|
||||
/* temp fix */
|
||||
memcpy(&groupchats[i].oldpeer_names[0], UNKNOWN_NAME, sizeof(UNKNOWN_NAME));
|
||||
groupchats[i].oldpeer_name_lengths[0] = (uint16_t) strlen(UNKNOWN_NAME);
|
||||
|
||||
set_active_window(groupchats[i].chatwin);
|
||||
|
||||
@ -95,6 +97,7 @@ static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
|
||||
free(groupchats[groupnum].peer_names);
|
||||
free(groupchats[groupnum].oldpeer_names);
|
||||
free(groupchats[groupnum].peer_name_lengths);
|
||||
free(groupchats[groupnum].oldpeer_name_lengths);
|
||||
memset(&groupchats[groupnum], 0, sizeof(GroupChat));
|
||||
|
||||
int i;
|
||||
|
Loading…
Reference in New Issue
Block a user