Commit ec6b2437 authored by Beniamino Galvani's avatar Beniamino Galvani

cli: fix crash on autocompletion

@connections is NULL when doing autocompletion. Fixes the following:

 $ nmcli --complete-args con monitor ""
  help
  id
  uuid
  path
  filename
  ...
  Segmentation fault (core dumped)

Fixes: 4b329727 ('cli: rework connection handling for multiple results')

https://bugzilla.redhat.com/show_bug.cgi?id=1716948
!177
(cherry picked from commit 6a3bb90a)
(cherry picked from commit 52c886a6)
parent 2666aa0b
......@@ -8782,6 +8782,9 @@ do_connection_monitor (NmCli *nmc, int argc, char **argv)
}
}
if (nmc->complete)
return nmc->return_value;
for (i = 0; i < connections->len; i++)
connection_watch (nmc, connections->pdata[i]);
......@@ -8791,8 +8794,6 @@ do_connection_monitor (NmCli *nmc, int argc, char **argv)
g_signal_connect (nmc->client, NM_CLIENT_CONNECTION_ADDED, G_CALLBACK (connection_added), nmc);
}
if (nmc->complete)
return nmc->return_value;
g_signal_connect (nmc->client, NM_CLIENT_CONNECTION_REMOVED, G_CALLBACK (connection_removed), nmc);
return NMC_RESULT_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment