diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-02-04 16:47:00 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-02-11 17:01:03 +0100 |
commit | e8927c14ec3e830099e1525fa8fee4c9a7fc5032 (patch) | |
tree | 068ea7a7f14eb9cc500e3cd10b41bce0d881f770 | |
parent | 1783826856e13d5234e5968720adb36f1464c845 (diff) | |
download | NetworkManager-e8927c14ec3e830099e1525fa8fee4c9a7fc5032.tar.gz |
client: fix NULL dereference with no connections
Coverity complains:
CID 59386 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking cons suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.
-rw-r--r-- | clients/cli/connections.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 33e6b5d943..44f7d8b12d 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1532,11 +1532,14 @@ sort_connections (const GPtrArray *cons, NmCli *nmc, const GArray *order) int i; NmcSortInfo compare_info; + if (!cons) + return; + compare_info.nmc = nmc; compare_info.order = order; sorted = g_ptr_array_sized_new (cons->len); - for (i = 0; cons && i < cons->len; i++) + for (i = 0; i < cons->len; i++) g_ptr_array_add (sorted, cons->pdata[i]); g_ptr_array_sort_with_data (sorted, compare_connections, &compare_info); return sorted; |