mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 13:30:08 +01:00
ifcfg-rh: fix memleak in svSetValue()
(cherry picked from commit 98a0299265)
This commit is contained in:
parent
3e1055d141
commit
2ceea73dc3
1 changed files with 8 additions and 8 deletions
|
|
@ -372,10 +372,12 @@ svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim)
|
|||
if (oldval) {
|
||||
/* delete line */
|
||||
s->lineList = g_list_remove_link (s->lineList, s->current);
|
||||
g_free (s->current->data);
|
||||
g_list_free_1 (s->current);
|
||||
s->modified = TRUE;
|
||||
}
|
||||
goto bail; /* do not need keyValue */
|
||||
g_free (keyValue);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!oldval) {
|
||||
|
|
@ -387,21 +389,19 @@ svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim)
|
|||
|
||||
if (strcmp (oldval, newval) != 0) {
|
||||
/* change line */
|
||||
if (s->current)
|
||||
if (s->current) {
|
||||
g_free (s->current->data);
|
||||
s->current->data = keyValue;
|
||||
else
|
||||
} else
|
||||
s->lineList = g_list_append (s->lineList, keyValue);
|
||||
s->modified = TRUE;
|
||||
}
|
||||
} else
|
||||
g_free (keyValue);
|
||||
|
||||
end:
|
||||
g_free (newval);
|
||||
g_free (oldval);
|
||||
return;
|
||||
|
||||
bail:
|
||||
g_free (keyValue);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Write the current contents iff modified. Returns FALSE on error
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue