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:
parent
cf9d44c326
commit
a25f1598de
|
@ -66,19 +66,24 @@ int mutator_set(Mutator * mutator, String const * key, void * value)
|
||||||
String * k;
|
String * k;
|
||||||
String * oldk;
|
String * oldk;
|
||||||
|
|
||||||
if(value == NULL)
|
/* look for the former key */
|
||||||
|
if((oldk = hash_get_key(mutator, key)) == NULL)
|
||||||
{
|
{
|
||||||
/* look for the former key */
|
if(value == NULL)
|
||||||
if((oldk = hash_get_key(mutator, key)) == NULL)
|
|
||||||
/* there is nothing to do */
|
/* there is nothing to do */
|
||||||
return 0;
|
return 0;
|
||||||
|
/* allocate the new key */
|
||||||
|
if((k = string_new(key)) == NULL)
|
||||||
|
return -1;
|
||||||
|
key = k;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
oldk = NULL;
|
{
|
||||||
/* allocate the key */
|
if(value != NULL)
|
||||||
if((k = string_new(key)) == NULL)
|
oldk = NULL;
|
||||||
return -1;
|
k = NULL;
|
||||||
if((ret = hash_set(mutator, k, value)) != 0)
|
}
|
||||||
|
if((ret = hash_set(mutator, key, value)) != 0)
|
||||||
{
|
{
|
||||||
error_set("%s: %s", key, "Could not set the value");
|
error_set("%s: %s", key, "Could not set the value");
|
||||||
string_delete(k);
|
string_delete(k);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user