]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Don't crash when @text is NULL in vshCompleterFilter()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 27 May 2024 09:06:41 +0000 (11:06 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 28 May 2024 06:52:31 +0000 (08:52 +0200)
This can happen only for cmdComplete() in interactive mode (which
I'm still not convinced is any useful for users and whether we
should support it). Anyway, running plain 'complete' command with
no additional arguments boils down to @text being NULL in
vshReadlineParse() which handles the case just right but is then
subsequently passed to vshCompleterFilter() which isn't prepared
for this case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tools/vsh.c

index c91d75688555ac33b536abb0094a1639b43ebdc2..6cc1f60d87cfba9c137d62c9fdde0da53c96c544 100644 (file)
@@ -2820,7 +2820,7 @@ vshCompleterFilter(char ***list,
     newList = g_new0(char *, list_len + 1);
 
     for (i = 0; i < list_len; i++) {
-        if (!STRPREFIX((*list)[i], text)) {
+        if (text && !STRPREFIX((*list)[i], text)) {
             g_clear_pointer(&(*list)[i], g_free);
             continue;
         }