summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-06-28 14:28:58 +0200
committerThomas Haller <thaller@redhat.com>2017-06-28 14:46:15 +0200
commit8efeb3688cd25a53c324f595f774f80276f90d65 (patch)
treebad93f49d4fec7a6816e63d928a7d25eb247d2be
parent870f4938535d260212a8667246c660019f03d202 (diff)
downloadNetworkManager-8efeb3688cd25a53c324f595f774f80276f90d65.tar.gz
cli: fix returning no results in complete function
For consistency, never return an empty array @values. If we have an empty array, instead return NULL. Also fixes commit afac7621a "clients: return NULL array on auto-completion failure", which claims that readline crashes with empty strv arrays. Fixes: afac7621ae3b306701fa388e31f57b082a5b1510
-rw-r--r--clients/common/nm-meta-setting-access.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/clients/common/nm-meta-setting-access.c b/clients/common/nm-meta-setting-access.c
index 47869f95c6..cd7ef783c4 100644
--- a/clients/common/nm-meta-setting-access.c
+++ b/clients/common/nm-meta-setting-access.c
@@ -283,10 +283,18 @@ nm_meta_abstract_info_complete (const NMMetaAbstractInfo *abstract_info,
nm_assert (!*out_to_free || values == (const char *const*) *out_to_free);
- if (!text || !text[0] || !values || !values[0])
+ if (!values)
+ return NULL;
+
+ if (!values[0]) {
+ nm_clear_g_free (out_to_free);
+ return NULL;
+ }
+
+ if (!text || !text[0])
return values;
- /* for convenience, we all the complete_fcn() implementations to
+ /* for convenience, we allow the complete_fcn() implementations to
* ignore "text". We filter out invalid matches here. */
text_len = strlen (text);