Commit 6f18af09 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix crash

parent 0b5494cd
......@@ -30,7 +30,7 @@
#define FILE_TRANSFER_KEY_SIZE 32
static bool_t file_transfer_in_progress_and_valid(LinphoneChatMessage* msg) {
return (msg->chat_room && msg->http_request && !belle_http_request_is_cancelled(msg->http_request));
return (msg->chat_room && msg->chat_room->lc && msg->http_request && !belle_http_request_is_cancelled(msg->http_request));
}
static void _release_http_request(LinphoneChatMessage* msg) {
......@@ -155,7 +155,7 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_
static void linphone_chat_message_process_response_from_post_file(void *data,
const belle_http_response_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
if (msg->http_request && !file_transfer_in_progress_and_valid(msg)) {
ms_warning("Cancelled request for %s msg [%p], ignoring %s", msg->chat_room?"":"ORPHAN", msg, __FUNCTION__);
_release_http_request(msg);
......@@ -316,18 +316,23 @@ const LinphoneContent *linphone_chat_message_get_file_transfer_information(const
static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, void *data, size_t offset,
const uint8_t *buffer, size_t size) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
LinphoneCore *lc = msg->chat_room->lc;
LinphoneCore *lc;
if (!msg->chat_room) {
linphone_chat_message_cancel_file_transfer(msg);
return;
}
lc = msg->chat_room->lc;
if (lc == NULL){
return; /*might happen during linphone_core_destroy()*/
}
if (!msg->http_request || belle_http_request_is_cancelled(msg->http_request)) {
ms_warning("Cancelled request for msg [%p], ignoring %s", msg, __FUNCTION__);
return;
}
if (!msg->chat_room) {
linphone_chat_message_cancel_file_transfer(msg);
}
/* first call may be with a zero size, ignore it */
if (size == 0) {
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment