summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-03-22 09:26:54 +0100
committerThomas Haller <thaller@redhat.com>2019-03-24 09:21:14 +0100
commit2a93ce91227eff1ecfad9eae671ac0291d8c244e (patch)
treec077eaba41f16a6db3bc6d33feebdc1766d87030
parent5478853a0b25fa33df10ca254b99c7cb493745d3 (diff)
downloadNetworkManager-2a93ce91227eff1ecfad9eae671ac0291d8c244e.tar.gz
libnm/team: preserve unset priv->runner_tx_hash in _align_team_properties()th/libnm-team-fixes
There is a difference between an unset JSON array element and an empty one. Don't loose that information.
-rw-r--r--libnm-core/nm-setting-team.c2
-rw-r--r--libnm-core/nm-utils-private.h3
-rw-r--r--libnm-core/nm-utils.c8
3 files changed, 6 insertions, 7 deletions
diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c
index 22cd3f737c..ec9d2ba02e 100644
--- a/libnm-core/nm-setting-team.c
+++ b/libnm-core/nm-setting-team.c
@@ -1397,7 +1397,7 @@ _align_team_properties (NMSettingTeam *setting)
NM_CAST_STRV_CC (strv),
-1) != 0) {
nm_clear_pointer (&priv->runner_tx_hash, g_ptr_array_unref);
- if (strv && strv[0]) {
+ if (strv) {
priv->runner_tx_hash = g_ptr_array_new_full (NM_PTRARRAY_LEN (strv), g_free);
for (i = 0; strv[i]; i++)
g_ptr_array_add (priv->runner_tx_hash, strv[i]);
diff --git a/libnm-core/nm-utils-private.h b/libnm-core/nm-utils-private.h
index 19e140851c..f730d3d365 100644
--- a/libnm-core/nm-utils-private.h
+++ b/libnm-core/nm-utils-private.h
@@ -179,7 +179,8 @@ _nm_utils_json_extract_strv (char *conf,
if ( !t_value
|| !G_TYPE_CHECK_VALUE_TYPE (t_value, G_TYPE_STRV))
return NULL;
- return g_strdupv (g_value_get_boxed (t_value));
+ return g_strdupv (g_value_get_boxed (t_value))
+ ?: g_new0 (char *, 1);
}
static inline GPtrArray *
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 17cc8f488f..854bfec794 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -5898,11 +5898,9 @@ _nm_utils_team_config_get (const char *conf,
if (json_is_string (str_element))
g_ptr_array_add (data, g_strdup (json_string_value (str_element)));
}
- if (data->len) {
- g_value_init (value, G_TYPE_STRV);
- g_value_take_boxed (value, _nm_utils_ptrarray_to_strv (data));
- }
- g_ptr_array_free (data, TRUE);
+ g_ptr_array_add (data, NULL);
+ g_value_init (value, G_TYPE_STRV);
+ g_value_take_boxed (value, g_ptr_array_free (data, FALSE));
} else {
g_assert_not_reached ();
g_free (value);