iface-modem-messaging: if sms list doesn't exist, free part
If the device goes away while we are listing SMS messages, it may happen that we ask the messaging interface to take a part and the sms list object has already been disposed. Make sure the part is freed in that case, so that we avoid memory leaks. ==19138== 6,914 (1,232 direct, 5,682 indirect) bytes in 11 blocks are definitely lost in loss record 5,282 of 5,287 ==19138== at 0x483A77F: malloc (vg_replace_malloc.c:307) ==19138== by 0x5023349: g_malloc (in /usr/lib/libglib-2.0.so.0.6600.0) ==19138== by 0x50446FF: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.6600.0) ==19138== by 0x5044D6A: g_slice_alloc0 (in /usr/lib/libglib-2.0.so.0.6600.0) ==19138== by 0x2577FC: mm_sms_part_new (mm-sms-part.c:180) ==19138== by 0x2504D0: mm_sms_part_3gpp_new_from_binary_pdu (mm-sms-part-3gpp.c:385) ==19138== by 0x21A15C: add_sms_part (mm-broadband-modem-mbim.c:5169) ==19138== by 0x21A31F: sms_read_query_ready (mm-broadband-modem-mbim.c:5215) ==19138== by 0x4E600F3: ??? (in /usr/lib/libgio-2.0.so.0.6600.0) ==19138== by 0x4E64638: ??? (in /usr/lib/libgio-2.0.so.0.6600.0) ==19138== by 0x4D3870D: transaction_task_complete_and_free (mbim-device.c:236) ==19138== by 0x4D396B9: process_message (mbim-device.c:616)
This commit is contained in:
@@ -410,29 +410,27 @@ handle_list (MmGdbusModemMessaging *skeleton,
|
||||
|
||||
gboolean
|
||||
mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
|
||||
MMSmsPart *sms_part,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage)
|
||||
MMSmsPart *sms_part,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage)
|
||||
{
|
||||
MMSmsList *list = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean added;
|
||||
g_autoptr(MMSmsList) list = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean added = FALSE;
|
||||
|
||||
g_object_get (self,
|
||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||
NULL);
|
||||
if (!list)
|
||||
return FALSE;
|
||||
|
||||
added = mm_sms_list_take_part (list, sms_part, state, storage, &error);
|
||||
if (!added) {
|
||||
mm_obj_dbg (self, "couldn't take part in SMS list: %s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
/* If part wasn't taken, we need to free the part ourselves */
|
||||
mm_sms_part_free (sms_part);
|
||||
if (list) {
|
||||
added = mm_sms_list_take_part (list, sms_part, state, storage, &error);
|
||||
if (!added)
|
||||
mm_obj_dbg (self, "couldn't take part in SMS list: %s", error->message);
|
||||
}
|
||||
g_object_unref (list);
|
||||
|
||||
/* If part wasn't taken, we need to free the part ourselves */
|
||||
if (!added)
|
||||
mm_sms_part_free (sms_part);
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user