diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index 7a2a16f74..1731673f9 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -1073,7 +1073,8 @@ get_property (GObject *object, guint prop_id, g_value_take_boxed (value, priv->seen_bssids ? nm_utils_strv_dup (priv->seen_bssids->pdata, - priv->seen_bssids->len) + priv->seen_bssids->len, + TRUE) : NULL); break; case PROP_HIDDEN: diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 34d5de120..60f1bfaf8 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -2393,6 +2393,10 @@ nm_utils_strv_make_deep_copied_n (const char **strv, gsize len) * is negative or zero (in which case %NULL will be returned). * @len: the length of strings in @str. If negative, strv is assumed * to be a NULL terminated array. + * @deep_copied: if %TRUE, clones the individual strings. In that case, + * the returned array must be freed with g_strfreev(). Otherwise, the + * strings themself are not copied. You must take care of who owns the + * strings yourself. * * Like g_strdupv(), with two differences: * @@ -2407,10 +2411,13 @@ nm_utils_strv_make_deep_copied_n (const char **strv, gsize len) * array with g_strfreev(). Allowing that would be error prone. * * Returns: (transfer full): a clone of the strv array. Always - * %NULL terminated. + * %NULL terminated. Depending on @deep_copied, the strings are + * cloned or not. */ char ** -nm_utils_strv_dup (gpointer strv, gssize len) +nm_utils_strv_dup (gpointer strv, + gssize len, + gboolean deep_copied) { gsize i, l; char **v; @@ -2438,7 +2445,10 @@ nm_utils_strv_dup (gpointer strv, gssize len) g_return_val_if_reached (v); } - v[i] = g_strdup (src[i]); + if (deep_copied) + v[i] = g_strdup (src[i]); + else + v[i] = (char *) src[i]; } v[l] = NULL; return v; diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index ff1ea17e2..c027769aa 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -990,7 +990,9 @@ nm_utils_strv_make_deep_copied_nonnull (const char **strv) return nm_utils_strv_make_deep_copied (strv) ?: g_new0 (char *, 1); } -char **nm_utils_strv_dup (gpointer strv, gssize len); +char **nm_utils_strv_dup (gpointer strv, + gssize len, + gboolean deep_copied); /*****************************************************************************/ diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 0366a66c6..b5868b7b1 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -1663,7 +1663,7 @@ set_property (GObject *object, specs = g_slist_prepend (specs, spec); } - priv->no_auto_default.arr = nm_utils_strv_dup (value_arr, j); + priv->no_auto_default.arr = nm_utils_strv_dup (value_arr, j, TRUE); priv->no_auto_default.specs = g_slist_reverse (specs); } break;