libnm-core: return NULL from _nm_utils_slist_to_strv for empty lists

The function is used, among others, in the get_property() of many
objects to return a boxed strv from a list. The default value for a
boxed strv property is NULL, but _nm_utils_slist_to_strv() returns a
pointer to an array with zero elements when the list is empty.

Change the function to return NULL if the input list is empty.
This commit is contained in:
Beniamino Galvani 2017-01-23 14:26:06 +01:00
parent f7875a42b0
commit 660bb1a48f

View file

@ -819,6 +819,8 @@ _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy)
int len, i;
len = g_slist_length (slist);
if (!len)
return NULL;
strv = g_new (char *, len + 1);
if (deep_copy) {