Desktop: Fix incorrect use of 'free()'.

Use 'xmlFree()' to free memory returned by libxml.
Follow-up to #3900.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-05-19 13:40:40 +12:00 committed by bstoeger
parent d7bfb9d61e
commit 84d9d0abe7

View file

@ -2341,16 +2341,16 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const struct xml_params *params
xmlDoc *transformed; xmlDoc *transformed;
xsltStylesheetPtr xslt = NULL; xsltStylesheetPtr xslt = NULL;
xmlNode *root_element = xmlDocGetRootElement(doc); xmlNode *root_element = xmlDocGetRootElement(doc);
char *attribute; xmlChar *attribute;
while (info->root) { while (info->root) {
if ((strcasecmp((const char *)root_element->name, info->root) == 0)) { if ((strcasecmp((const char *)root_element->name, info->root) == 0)) {
if (info->attribute == NULL) if (info->attribute == NULL)
break; break;
void *prop = xmlGetProp(root_element, (const xmlChar *)info->attribute); xmlChar *prop = xmlGetProp(root_element, (const xmlChar *)info->attribute);
if (prop != NULL) { if (prop != NULL) {
free(prop); xmlFree(prop);
break; break;
} }
@ -2359,13 +2359,13 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const struct xml_params *params
} }
if (info->root) { if (info->root) {
attribute = (char *)xmlGetProp(xmlFirstElementChild(root_element), (const xmlChar *)"name"); attribute = xmlGetProp(xmlFirstElementChild(root_element), (const xmlChar *)"name");
if (attribute) { if (attribute) {
if (strcasecmp(attribute, "subsurface") == 0) { if (strcasecmp((char *)attribute, "subsurface") == 0) {
free((void *)attribute); xmlFree(attribute);
return doc; return doc;
} }
free((void *)attribute); xmlFree(attribute);
} }
xmlSubstituteEntitiesDefault(1); xmlSubstituteEntitiesDefault(1);
xslt = get_stylesheet(info->file); xslt = get_stylesheet(info->file);