From 660bb1a48f78cafb280e72c00c1bf0ea818f1538 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 23 Jan 2017 14:26:06 +0100 Subject: [PATCH] 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. --- libnm-core/nm-utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 5b4566bf41..4949033dd9 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -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) {