modem-helpers: do not leak past PDP on error

If CID parsing from the +CGDCONT response fails, the very last PDP
structure allocated is not put on the list yet and therefore
mm_3gpp_pdp_context_list_free() wouldn't free it.

Let's put it on the list first, as to not leak it on error.
This commit is contained in:
Lubomir Rintel
2024-05-31 10:46:59 +00:00
committed by Aleksander Morgado
parent bd0551460b
commit df8287bf6c
+2 -2
View File
@@ -1870,6 +1870,8 @@ mm_3gpp_parse_cgdcont_read_response (const gchar *reply,
MM3gppPdpContext *pdp;
pdp = g_slice_new0 (MM3gppPdpContext);
list = g_list_prepend (list, pdp);
if (!mm_get_uint_from_match_info (match_info, 1, &pdp->cid)) {
inner_error = g_error_new (MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
@@ -1879,8 +1881,6 @@ mm_3gpp_parse_cgdcont_read_response (const gchar *reply,
}
pdp->pdp_type = ip_family;
pdp->apn = mm_get_string_unquoted_from_match_info (match_info, 3);
list = g_list_prepend (list, pdp);
}
g_free (str);