mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-15 00:48:05 +02:00
cli: fix crash in complete function
$ nmcli --complete-args connection import type non-existing-<TAB>
Leads to a double-free of out_to_free, as we call g_free(v) in
nm_meta_abstract_info_complete().
Also fix a memleak when skipping over non-matching values.
Fixes: afac7621ae
This commit is contained in:
parent
699492c1a5
commit
870f493853
1 changed files with 4 additions and 2 deletions
|
|
@ -295,15 +295,17 @@ nm_meta_abstract_info_complete (const NMMetaAbstractInfo *abstract_info,
|
|||
char **v = *out_to_free;
|
||||
|
||||
for (i = 0, j = 0; v[i]; i++) {
|
||||
if (strncmp (v[i], text, text_len) != 0)
|
||||
if (strncmp (v[i], text, text_len) != 0) {
|
||||
g_free (v[i]);
|
||||
continue;
|
||||
}
|
||||
v[j++] = v[i];
|
||||
}
|
||||
if (j)
|
||||
v[j++] = NULL;
|
||||
else {
|
||||
g_free (v);
|
||||
v = NULL;
|
||||
*out_to_free = v = NULL;
|
||||
}
|
||||
return (const char *const*) v;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue