[PATCH] broadband-modem: fix an ineffective `g_assert (equip_id)'

Ben Chan benchan at chromium.org
Thu Aug 3 21:41:11 UTC 2017


This patch fixes an ineffective `g_assert (equip_id)' in
modem_load_equipment_identifier_finish(). After mm_parse_gsn() succeeds,
`equip_id' is freed but not reset to NULL, so `g_assert (equip_id)' will
never assert even if `imei', `meid', and `esn' are all NULL (though that
shouldn't happen when mm_parse_gsn() succeeds).
---
 src/mm-broadband-modem.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 2bfc3382..3e30aa90 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -901,7 +901,7 @@ modem_load_equipment_identifier_finish (MMIfaceModem *self,
 
         /* Modems put all sorts of things into the GSN response; sanitize it */
         if (mm_parse_gsn (equip_id, &imei, &meid, &esn)) {
-            g_free (equip_id);
+            g_clear_pointer (&equip_id, g_free);
 
             if (imei)
                 equip_id = g_strdup (imei);
@@ -909,11 +909,12 @@ modem_load_equipment_identifier_finish (MMIfaceModem *self,
                 equip_id = g_strdup (meid);
             else if (esn)
                 equip_id = g_strdup (esn);
+            else
+                g_assert_not_reached ();
+
             g_free (esn);
             g_free (meid);
             g_free (imei);
-
-            g_assert (equip_id);
         } else {
             /* Leave whatever the modem returned alone */
         }
-- 
2.14.0.rc1.383.gd1ce394fe2-goog



More information about the ModemManager-devel mailing list