From 1fc280f4cc2e52b65eeb5dfcd1f3e3204490995c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 5 Jun 2019 15:17:08 +0200 Subject: 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: 4b3297271e6f ('cli: rework connection handling for multiple results') https://bugzilla.redhat.com/show_bug.cgi?id=1716948 --- clients/cli/connections.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index c7230f5c69..1ca84ba575 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -8741,6 +8741,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]); @@ -8750,8 +8753,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; -- cgit v1.2.1