Huawei: memory leak when parsing ^HCSQ response
Hi,
when investing a ModemManager high memory usage case, I found a small memory leak with valgrind tool. I am using ModemManager 1.12.10 and a Huawei MS2372h USB modem in broadband mode.
==2311== 100 bytes in 4 blocks are definitely lost in loss record 3,855 of 4,434
==2311== at 0x4808D93: malloc (vg_replace_malloc.c:299)
==2311== by 0x4C315A0: g_malloc (gmem.c:99)
==2311== by 0x4C4B1F9: g_strndup (gstrfuncs.c:425)
==2311== by 0x4C3E9A0: g_match_info_fetch (gregex.c:1004)
==2311== by 0x75ADA8E: huawei_hcsq_changed (mm-broadband-modem-huawei.c:1799)
==2311== by 0x1A098E: parse_unsolicited (mm-port-serial-at.c:284)
==2311== by 0x19EC60: parse_response_buffer (mm-port-serial.c:915)
==2311== by 0x19EC60: common_input_available (mm-port-serial.c:1049)
==2311== by 0x4C2BA77: g_main_dispatch (gmain.c:3182)
==2311== by 0x4C2BA77: g_main_context_dispatch (gmain.c:3847)
==2311== by 0x4C2BE67: g_main_context_iterate.isra.26 (gmain.c:3920)
==2311== by 0x4C2C161: g_main_loop_run (gmain.c:4116)
==2311== by 0x13183E: main (main.c:206)
==2311==
I made a patch (based on master branch) that fixes the leak on my setup. 0001-huawei-fix-memory-leak-when-parsing-HCSQ-response.patch
Regards,
Edited by Louis-Alexis Eyraud