Add the ability to call load_settings more than once
free_ini() didn't properly reset `section_count` and `sections` which caused a segfault if load_ini_file was called multiple times in the same run.
This commit is contained in:
parent
63bb4ad857
commit
a788770a0f
@ -50,6 +50,7 @@ section_t *new_section(char *name)
|
||||
|
||||
section_count++;
|
||||
sections = realloc(sections, sizeof(section_t) * section_count);
|
||||
if(sections == NULL) die("Unable to allocate memory.\n", 1);
|
||||
sections[section_count - 1].name = g_strdup(name);
|
||||
sections[section_count - 1].entries = NULL;
|
||||
sections[section_count - 1].entry_count = 0;
|
||||
@ -67,6 +68,8 @@ void free_ini(void)
|
||||
free(sections[i].name);
|
||||
}
|
||||
free(sections);
|
||||
section_count = 0;
|
||||
sections = NULL;
|
||||
}
|
||||
|
||||
section_t *get_section(char *name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user