Commit e0c05ef8 authored by Marvin Scholz's avatar Marvin Scholz

Fix another memory leak in xslt loader

This fixes another memory leak, which was caused by not freeing
the admin_path when a subsequent xslt file was loaded.
parent 06545b25
...@@ -202,10 +202,11 @@ static xmlDocPtr custom_loader(const xmlChar *URI, ...@@ -202,10 +202,11 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
void *ctxt, void *ctxt,
xsltLoadType type) xsltLoadType type)
{ {
int len;
xmlDocPtr ret; xmlDocPtr ret;
xmlChar *rel_path, *fn, *final_URI = NULL; xmlChar *rel_path, *fn, *final_URI = NULL;
xsltStylesheet *c; xsltStylesheet *c;
ice_config_t *config; ice_config_t *conf;
switch (type) { switch (type) {
/* In case an include is loaded */ /* In case an include is loaded */
case XSLT_LOAD_STYLESHEET: case XSLT_LOAD_STYLESHEET:
...@@ -232,10 +233,20 @@ static xmlDocPtr custom_loader(const xmlChar *URI, ...@@ -232,10 +233,20 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
break; break;
/* In case a top stylesheet is loaded */ /* In case a top stylesheet is loaded */
case XSLT_LOAD_START: case XSLT_LOAD_START:
config = config_get_config(); conf = config_get_config();
admin_path = xmlCharStrdup(config->adminroot_dir); len = strlen(conf->adminroot_dir);
if (admin_path != NULL &&
strncmp(conf->adminroot_dir, (char *)admin_path, len) != 0) {
xmlFree(admin_path);
admin_path = NULL;
}
if (admin_path == NULL) {
admin_path = xmlMemMalloc(len+2);
if (admin_path == NULL)
return NULL;
xmlStrPrintf(admin_path, len+2, XMLSTR("%s/"), XMLSTR(conf->adminroot_dir));
}
config_release_config(); config_release_config();
admin_path = xmlStrcat(admin_path, (xmlChar *)"/");
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment