Index: libconfig.c ================================================================== --- libconfig.c +++ libconfig.c @@ -770,10 +770,13 @@ int lc_process_var(const char *var, const char *varargs, const char *value, lc_flags_t flags) { struct lc_varhandler_st *handler = NULL; const char *lastcomponent_handler = NULL, *lastcomponent_var = NULL; + lc_errno = LC_ERR_NONE; + lc_err_usererrmsg = NULL; + lastcomponent_var = strrchr(var, '.'); if (lastcomponent_var == NULL) { lastcomponent_var = var; } else { lastcomponent_var++; @@ -819,10 +822,13 @@ } int lc_register_callback(const char *var, char opt, lc_var_type_t type, int (*callback)(const char *, const char *, const char *, const char *, lc_flags_t, void *), void *extra) { struct lc_varhandler_st *newhandler = NULL; + lc_errno = LC_ERR_NONE; + lc_err_usererrmsg = NULL; + newhandler = malloc(sizeof(*newhandler)); if (newhandler == NULL) { return(-1); } @@ -845,10 +851,13 @@ } int lc_register_var(const char *var, lc_var_type_t type, void *data, char opt) { struct lc_varhandler_st *newhandler = NULL; + lc_errno = LC_ERR_NONE; + lc_err_usererrmsg = NULL; + newhandler = malloc(sizeof(*newhandler)); if (newhandler == NULL) { return(-1); } @@ -871,10 +880,13 @@ } int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type) { int chkretval = 0; + lc_errno = LC_ERR_NONE; + lc_err_usererrmsg = NULL; + switch (type) { case LC_CONF_SECTION: chkretval = lc_process_conf_section(appname, pathname); break; case LC_CONF_APACHE: @@ -968,10 +980,13 @@ } void lc_cleanup(void) { struct lc_varhandler_st *handler = NULL, *next = NULL; + lc_errno = LC_ERR_NONE; + lc_err_usererrmsg = NULL; + handler = varhandlers; while (handler != NULL) { if (handler->var != NULL) { free(handler->var); } @@ -1022,12 +1037,10 @@ lc_err_t lc_geterrno(void) { lc_err_t retval; retval = lc_errno; - lc_errno = LC_ERR_NONE; - return(retval); } void lc_seterrstr(const char *usererrmsg) { lc_err_usererrmsg = strdup(usererrmsg);