[PATCH] mbimcli: use g_strfreev instead of g_free to free g_strsplit results
Aleksander Morgado
aleksander at aleksander.es
Mon Feb 24 12:43:50 PST 2014
On Mon, Feb 24, 2014 at 6:12 PM, Ben Chan <benchan at chromium.org> wrote:
> 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.
> ---
Pushed, thanks.
> src/mbimcli/mbimcli-basic-connect.c | 15 +++++++--------
> 1 file 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;
> }
>
> --
> 1.9.0.rc1.175.g0b1dcb5
>
--
Aleksander
https://aleksander.es
More information about the libmbim-devel
mailing list