mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 05:50:28 +01:00
libnm-core: fix getting/setting 0-length array properties
Empty array-valued properties should return a 0-length array from get_property(), but should also accept NULL as equivalent to a 0-length array from set_property().
This commit is contained in:
parent
b9f9fd39ab
commit
6c6cec0366
1 changed files with 10 additions and 5 deletions
|
|
@ -618,6 +618,9 @@ _nm_utils_copy_array_to_slist (const GPtrArray *array,
|
|||
gpointer item;
|
||||
int i;
|
||||
|
||||
if (!array)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < array->len; i++) {
|
||||
item = array->pdata[i];
|
||||
slist = g_slist_prepend (slist, copy_func (item));
|
||||
|
|
@ -634,6 +637,9 @@ _nm_utils_copy_array (const GPtrArray *array,
|
|||
GPtrArray *copy;
|
||||
int i;
|
||||
|
||||
if (!array)
|
||||
return g_ptr_array_new_with_free_func (free_func);
|
||||
|
||||
copy = g_ptr_array_new_full (array->len, free_func);
|
||||
for (i = 0; i < array->len; i++)
|
||||
g_ptr_array_add (copy, copy_func (array->pdata[i]));
|
||||
|
|
@ -681,8 +687,10 @@ _nm_utils_strv_to_slist (char **strv)
|
|||
int i;
|
||||
GSList *list = NULL;
|
||||
|
||||
for (i = 0; strv && strv[i]; i++)
|
||||
list = g_slist_prepend (list, g_strdup (strv[i]));
|
||||
if (strv) {
|
||||
for (i = 0; strv[i]; i++)
|
||||
list = g_slist_prepend (list, g_strdup (strv[i]));
|
||||
}
|
||||
|
||||
return g_slist_reverse (list);
|
||||
}
|
||||
|
|
@ -694,9 +702,6 @@ _nm_utils_slist_to_strv (GSList *slist)
|
|||
char **strv;
|
||||
int len, i = 0;
|
||||
|
||||
if (slist == NULL)
|
||||
return NULL;
|
||||
|
||||
len = g_slist_length (slist);
|
||||
strv = g_new (char *, len + 1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue