The reference counter wasn't correctly initialized which cause that the
configuration struct was freed too soon but still accessed.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
if (!c)
return ENOMEM;
+ // Initialize reference counter
+ c->nrefs = 1;
+
// Initialise entries
STAILQ_INIT(&c->entries);
}
struct pakfire_config* pakfire_config_ref(struct pakfire_config* config) {
- config->nrefs++;
+ ++config->nrefs;
return config;
}
}
struct pakfire_config* pakfire_get_config(Pakfire pakfire) {
- if (pakfire->config)
- return pakfire_config_ref(pakfire->config);
+ if (!pakfire->config)
+ return NULL;
- return NULL;
+ return pakfire_config_ref(pakfire->config);
}
PAKFIRE_EXPORT const char* pakfire_get_path(Pakfire pakfire) {