libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit ea9ce7e9c4a6caf6fc192e861335fd48d07e6035
parent 78fb1b50905b8ea307f8d803db3225bb26350298
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 15 Feb 2017 10:22:46 +0100

Fix(Conig): Missing inits and free order

Diffstat:
Msrc/config.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -97,11 +97,12 @@ config_t *parse_config(const char *path, u8_t *ret) { config = malloc(sizeof(config_t)); assert(config != NULL); config->fn = NULL; + config->err = NULL; config->ptr = cfg_init(opts, CFGF_NONE); cfg_set_error_function(config->ptr, &config_error_cb); *ret = cfg_parse(config->ptr, path != NULL ? path : CONFIG_DEF_PATH); - config->fn = malloc(strlen(path != NULL ? path : CONFIG_DEF_PATH)); + config->fn = malloc(strlen(path != NULL ? path : CONFIG_DEF_PATH) + 1); strcpy(config->fn, path != NULL ? path : CONFIG_DEF_PATH); if (ret != 0) config_get_error_string(config); @@ -116,9 +117,9 @@ config_t *parse_config(const char *path, u8_t *ret) { void config_free(config_t *ptr) { if (ptr != NULL) { cfg_free(ptr->ptr); - free(ptr); free(ptr->fn); free(ptr->err); + free(ptr); } }