ifcfg-rh: fix memleak in svSetValue()

(cherry picked from commit 98a0299265)
This commit is contained in:
Thomas Haller 2015-02-07 16:27:49 +01:00
parent 3e1055d141
commit 2ceea73dc3

View file

@ -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