mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Fixed memory leaks in custom xslt loader
This fixes some memory leaks in the xslt loader, additionally it now makes no copy of the URI if not needed.
This commit is contained in:
parent
0709b4e66d
commit
06545b25c0
26
src/xslt.c
26
src/xslt.c
@ -203,27 +203,31 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
|
||||
xsltLoadType type)
|
||||
{
|
||||
xmlDocPtr ret;
|
||||
xmlChar *rel_path, *fn, *final_URI;
|
||||
xmlChar *rel_path, *fn, *final_URI = NULL;
|
||||
xsltStylesheet *c;
|
||||
ice_config_t *config;
|
||||
final_URI = xmlStrdup(URI);
|
||||
struct stat file;
|
||||
switch (type) {
|
||||
/* In case an include is loaded */
|
||||
case XSLT_LOAD_STYLESHEET:
|
||||
/* Not look in admindir if the include file exists */
|
||||
if (stat((char *)URI, &file) == 0)
|
||||
if (access((char *)URI, F_OK) == 0)
|
||||
break;
|
||||
c = (xsltStylesheet *) ctxt;
|
||||
/* Check if we actually have context/path */
|
||||
if (ctxt == NULL || c->doc->URL == NULL)
|
||||
break;
|
||||
/* Construct the right path */
|
||||
rel_path = xmlBuildRelativeURI(URI, c->doc->URL);
|
||||
if (rel_path != NULL && admin_path != NULL) {
|
||||
fn = xmlBuildURI(rel_path, admin_path);
|
||||
if (fn != NULL && stat((char *)fn, &file) == 0) {
|
||||
final_URI = fn;
|
||||
}
|
||||
final_URI = fn;
|
||||
xmlFree(rel_path);
|
||||
}
|
||||
/* Fail if there was an error constructing the path */
|
||||
if (final_URI == NULL) {
|
||||
if (rel_path)
|
||||
xmlFree(rel_path);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
/* In case a top stylesheet is loaded */
|
||||
@ -238,8 +242,12 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
|
||||
break;
|
||||
}
|
||||
/* Get the actual xmlDoc */
|
||||
ret = xslt_loader(final_URI, dict, options, ctxt, type);
|
||||
xmlFree(final_URI);
|
||||
if (final_URI) {
|
||||
ret = xslt_loader(final_URI, dict, options, ctxt, type);
|
||||
xmlFree(final_URI);
|
||||
} else {
|
||||
ret = xslt_loader(URI, dict, options, ctxt, type);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user