mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-28 07:30:37 +01: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)') (cherry picked from commitca47fd882e) (cherry picked from commit796844dc09) (cherry picked from commitd13f0c04ed)
This commit is contained in:
parent
8ef11d8179
commit
6d0fe8cffa
1 changed files with 9 additions and 2 deletions
|
|
@ -6565,8 +6565,15 @@ extract_setting_and_property(const char *prompt, const char *line, char **settin
|
|||
p2 = dot + 1;
|
||||
num1 = strcspn(p1, ".");
|
||||
num2 = len > num1 + 1 ? len - num1 - 1 : 0;
|
||||
sett = num1 > 0 ? g_strndup(p1, num1) : sett;
|
||||
prop = num2 > 0 ? g_strndup(p2, num2) : prop;
|
||||
if (num1 > 0) {
|
||||
g_free(sett);
|
||||
sett = g_strndup(p1, num1);
|
||||
}
|
||||
|
||||
if (num2 > 0) {
|
||||
g_free(prop);
|
||||
prop = g_strndup(p2, num2);
|
||||
}
|
||||
} else {
|
||||
if (!prop)
|
||||
prop = len > 0 ? g_strndup(p1, len) : NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue