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: afac7621ae
This commit is contained in:
Thomas Haller 2017-06-28 14:28:58 +02:00
parent 870f493853
commit 8efeb3688c

View file

@ -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);