fix RTT CRLF handling (not sure it is correct but at least it no longer does invalid reads)

fix memory leak
This commit is contained in:
Simon Morlat 2015-09-25 18:27:27 +02:00
parent 7cbbb6b17e
commit 46e3ae725a
3 changed files with 14 additions and 6 deletions

View file

@ -320,8 +320,9 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
/*stubed rtt text*/
if (cr->call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(cr->call))) {
char crlf[2] = "\r\n";
linphone_chat_message_put_char(msg, *(uint32_t*)crlf); // CRLF
linphone_chat_message_put_char(msg, *(uint16_t*)crlf); // CRLF
linphone_chat_message_set_state(msg, LinphoneChatMessageStateDelivered);
linphone_chat_message_unref(msg);
return;
}
linphone_chat_message_set_state(msg, LinphoneChatMessageStateInProgress);
@ -812,13 +813,16 @@ void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *c
cr->pending_message = linphone_chat_room_create_message(cr, "");
}
if (character == *(uint32_t*)crlf) {
if (character == (uint32_t)*(uint16_t*)crlf) {
// End of message
LinphoneChatMessage *msg = cr->pending_message;
ms_message("CRLF received, forge a message with content %s", cr->pending_message->message);
linphone_chat_message_set_from(msg, cr->peer_url);
linphone_chat_message_set_to(msg, linphone_address_new(linphone_core_get_identity(lc)));
if (msg->to)
linphone_address_destroy(msg->to);
msg->to = call->dest_proxy ? linphone_address_clone(call->dest_proxy->identity_address) :
linphone_address_new(linphone_core_get_identity(lc));
msg->time = ms_time(0);
msg->state = LinphoneChatMessageStateDelivered;
msg->is_read = FALSE;

View file

@ -3554,12 +3554,17 @@ void linphone_call_stop_media_streams(LinphoneCall *call){
if (call->audio_profile){
rtp_profile_destroy(call->audio_profile);
call->audio_profile=NULL;
unset_rtp_profile(call,0);
unset_rtp_profile(call,call->main_audio_stream_index);
}
if (call->video_profile){
rtp_profile_destroy(call->video_profile);
call->video_profile=NULL;
unset_rtp_profile(call,1);
unset_rtp_profile(call,call->main_video_stream_index);
}
if (call->text_profile){
rtp_profile_destroy(call->text_profile);
call->text_profile=NULL;
unset_rtp_profile(call,call->main_text_stream_index);
}
if (call->rtp_io_audio_profile) {
rtp_profile_destroy(call->rtp_io_audio_profile);

View file

@ -1320,7 +1320,6 @@ static void real_time_text_message(void) {
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(msg), message);
}
}
linphone_chat_message_destroy(rtt_message);
}
end_call(marie, pauline);
linphone_call_params_destroy(marie_params);