Fix a memory leak

It was unfortunately re-introduced from the Config class, when
correcting the key management for the Mutator class.
This commit is contained in:
Pierre Pronchery 2015-10-15 01:25:44 +02:00
parent cf9d44c326
commit a25f1598de

View File

@ -66,19 +66,24 @@ int mutator_set(Mutator * mutator, String const * key, void * value)
String * k;
String * oldk;
if(value == NULL)
{
/* look for the former key */
if((oldk = hash_get_key(mutator, key)) == NULL)
{
if(value == NULL)
/* there is nothing to do */
return 0;
}
else
oldk = NULL;
/* allocate the key */
/* allocate the new key */
if((k = string_new(key)) == NULL)
return -1;
if((ret = hash_set(mutator, k, value)) != 0)
key = k;
}
else
{
if(value != NULL)
oldk = NULL;
k = NULL;
}
if((ret = hash_set(mutator, key, value)) != 0)
{
error_set("%s: %s", key, "Could not set the value");
string_delete(k);