summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2014-02-24 09:12:57 -0800
committerAleksander Morgado <aleksander@aleksander.es>2014-02-24 21:40:23 +0100
commitdded15874b8d86f87fd5bacae63d9dc8e81fca0f (patch)
treef140fb2c09083c5e6ebed17f3f060627383c7c96
parent3fa4e1bbf6aea94a275a97029a90e2ed4022396b (diff)
downloadlibmbim-dded15874b8d86f87fd5bacae63d9dc8e81fca0f.tar.gz
mbimcli: use g_strfreev instead of g_free to free g_strsplit results
This patch modifies set_pin_input_parse and set_connect_activate_parse in mbimcli-basic-connect.c to duplicate the strings in a string array, before returning them to the caller, so that the string array can be properly freed with g_strfreev.
-rw-r--r--src/mbimcli/mbimcli-basic-connect.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/mbimcli/mbimcli-basic-connect.c b/src/mbimcli/mbimcli-basic-connect.c
index 97368aa..b97154c 100644
--- a/src/mbimcli/mbimcli-basic-connect.c
+++ b/src/mbimcli/mbimcli-basic-connect.c
@@ -639,10 +639,10 @@ set_pin_input_parse (guint n_expected,
return FALSE;
}
- *pin = split[0];
- *new_pin = split[1] ? split[1] : NULL;
+ *pin = g_strdup (split[0]);
+ *new_pin = g_strdup (split[1]);
- g_free (split);
+ g_strfreev (split);
return TRUE;
}
@@ -756,7 +756,7 @@ set_connect_activate_parse (const gchar *str,
}
/* APN */
- *apn = split[0];
+ *apn = g_strdup (split[0]);
/* Some defaults */
*auth_protocol = MBIM_AUTH_PROTOCOL_NONE;
@@ -776,15 +776,14 @@ set_connect_activate_parse (const gchar *str,
/* Username */
if (split[2]) {
- *username = split[2];
+ *username = g_strdup (split[2]);
/* Password */
- if (split[3])
- *password = split[3];
+ *password = g_strdup (split[3]);
}
}
- g_free (split);
+ g_strfreev (split);
return TRUE;
}