config_set_string - prevent potential crash
This commit is contained in:
parent
616f517de7
commit
7f3e63a18d
|
@ -771,8 +771,12 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
|
||||||
|
|
||||||
entry = (struct config_entry_list*)calloc(1, sizeof(*entry));
|
entry = (struct config_entry_list*)calloc(1, sizeof(*entry));
|
||||||
|
|
||||||
if (!entry)
|
if (!entry || !val)
|
||||||
|
{
|
||||||
|
if (entry)
|
||||||
|
free(entry);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entry->key = strdup(key);
|
entry->key = strdup(key);
|
||||||
entry->value = strdup(val);
|
entry->value = strdup(val);
|
||||||
|
|
Loading…
Reference in New Issue