mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 03:38:09 +02:00
nmcli/edit: fix memory leak in extract_setting_and_property
In case the user selects a setting/property with "goto" command, and
then attempts to tab-complete a setting/property pair, the original sett
and prop strings are overriden without freeing:
nmcli > goto 802-1x.pac-file
nmcli 802-1x.pac-file> set 802-1.lal<TAB>
Fixes: 79bc271685 ('cli: TAB-completion for enum-style property values (rh #1034126)')
This commit is contained in:
parent
76285d321f
commit
ca47fd882e
1 changed files with 9 additions and 2 deletions
|
|
@ -6584,8 +6584,15 @@ extract_setting_and_property(const char *prompt, const char *line, char **settin
|
||||||
p2 = dot + 1;
|
p2 = dot + 1;
|
||||||
num1 = strcspn(p1, ".");
|
num1 = strcspn(p1, ".");
|
||||||
num2 = len > num1 + 1 ? len - num1 - 1 : 0;
|
num2 = len > num1 + 1 ? len - num1 - 1 : 0;
|
||||||
sett = num1 > 0 ? g_strndup(p1, num1) : sett;
|
if (num1 > 0) {
|
||||||
prop = num2 > 0 ? g_strndup(p2, num2) : prop;
|
g_free(sett);
|
||||||
|
sett = g_strndup(p1, num1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num2 > 0) {
|
||||||
|
g_free(prop);
|
||||||
|
prop = g_strndup(p2, num2);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!prop)
|
if (!prop)
|
||||||
prop = len > 0 ? g_strndup(p1, len) : NULL;
|
prop = len > 0 ? g_strndup(p1, len) : NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue