Fixed some memory related bugs.

This commit is contained in:
irungentoo 2015-10-23 09:59:21 -04:00 committed by Eniz Vukovic
parent 4f3be9f354
commit b23819a4d1
2 changed files with 8 additions and 4 deletions

View File

@ -528,7 +528,7 @@ MSICall *new_call (MSISession *session, uint32_t friend_number)
session->calls_tail = session->calls_head = friend_number;
} else if (session->calls_tail < friend_number) { /* Appending */
void *tmp = realloc(session->calls, sizeof(MSICall *) * friend_number + 1);
void *tmp = realloc(session->calls, sizeof(MSICall *) * (friend_number + 1));
if (tmp == NULL) {
free(rc);

View File

@ -445,6 +445,7 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL co
goto END;
}
call->msi_call = NULL;
/* No mather the case, terminate the call */
call_kill_transmission(call);
call_remove(call);
@ -1037,8 +1038,8 @@ ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, TOXAV_ERR_CALL *error)
av->calls_tail = av->calls_head = friend_number;
} else if (av->calls_tail < friend_number) { /* Appending */
void *tmp = realloc(av->calls, sizeof(ToxAVCall *) * friend_number + 1);
} else if (av->calls_tail <= friend_number) { /* Appending */
void *tmp = realloc(av->calls, sizeof(ToxAVCall *) * (friend_number + 1));
if (tmp == NULL) {
free(call);
@ -1097,7 +1098,10 @@ ToxAVCall *call_remove(ToxAVCall *call)
/* Set av call in msi to NULL in order to know if call if ToxAVCall is
* removed from the msi call.
*/
call->msi_call->av_call = NULL;
if (call->msi_call) {
call->msi_call->av_call = NULL;
}
free(call);
if (prev)