You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ModemManager/SOURCES/0011-modem-helpers-do-not-l...

40 lines
1.4 KiB

From a877ed8015a4fcfb05961b5bfe9d03f47cdc55a5 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Mon, 27 May 2024 00:06:45 +0200
Subject: [PATCH 11/11] 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.
---
src/mm-modem-helpers.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 8dad5a398..9f0c8a8ce 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -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);
--
2.45.2