diff --git a/clients/common/nm-meta-setting-access.c b/clients/common/nm-meta-setting-access.c index 7a0cefde9d..f6038e1f1b 100644 --- a/clients/common/nm-meta-setting-access.c +++ b/clients/common/nm-meta-setting-access.c @@ -294,13 +294,18 @@ nm_meta_abstract_info_complete (const NMMetaAbstractInfo *abstract_info, if (*out_to_free) { char **v = *out_to_free; - for (i =0, j = 0; v[i]; i++) { + for (i = 0, j = 0; v[i]; i++) { if (strncmp (v[i], text, text_len) != 0) continue; v[j++] = v[i]; } - v[j++] = NULL; - return (const char *const*) *out_to_free; + if (j) + v[j++] = NULL; + else { + g_free (v); + v = NULL; + } + return (const char *const*) v; } else { const char *const*v = values; char **r; @@ -312,6 +317,8 @@ nm_meta_abstract_info_complete (const NMMetaAbstractInfo *abstract_info, } if (j == i) return values; + else if (!j) + return NULL; r = g_new (char *, j + 1); v = values; diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index 39d958c9f5..e071fce668 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -1759,7 +1759,12 @@ _complete_fcn_vpn_service_type (ARGS_COMPLETE_FCN) values[j] = values[i]; j++; } - values[j++] = NULL; + if (j) + values[j++] = NULL; + else { + g_free (values); + values = NULL; + } } return (const char *const*) (*out_to_free = values); } @@ -2378,7 +2383,12 @@ _complete_fcn_connection_type (ARGS_COMPLETE_FCN) result[j++] = g_strdup (v); } } - result[j++] = NULL; + if (j) + result[j++] = NULL; + else { + g_free (result); + result = NULL; + } return (const char *const*) (*out_to_free = result); } @@ -2526,10 +2536,14 @@ _complete_fcn_connection_master (ARGS_COMPLETE_FCN) if (v && (!text || strncmp (text, v, text_len) == 0)) result[j++] = g_strdup (v); } - result[j++] = NULL; + if (j) + result[j++] = NULL; + else { + g_free (result); + result = NULL; + } - *out_to_free = NULL; - return (const char *const*) result; + return (const char *const*) (*out_to_free = result); } static gboolean