mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
(RXML) Fix memory leak
This commit is contained in:
parent
f37d38bcd4
commit
5c50d2f389
@ -143,16 +143,6 @@ rxml_document_t *rxml_load_document_string(const char *str)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
doc->root_node = (struct rxml_node *)malloc(
|
|
||||||
sizeof(*doc->root_node));
|
|
||||||
|
|
||||||
doc->root_node->name = NULL;
|
|
||||||
doc->root_node->data = NULL;
|
|
||||||
doc->root_node->attrib = NULL;
|
|
||||||
|
|
||||||
doc->root_node->children = NULL;
|
|
||||||
doc->root_node->next = NULL;
|
|
||||||
|
|
||||||
yxml_init(&x, buf->xml, BUFSIZE);
|
yxml_init(&x, buf->xml, BUFSIZE);
|
||||||
|
|
||||||
for (; *str; ++str)
|
for (; *str; ++str)
|
||||||
@ -256,30 +246,14 @@ rxml_document_t *rxml_load_document_string(const char *str)
|
|||||||
|
|
||||||
case YXML_ATTRSTART:
|
case YXML_ATTRSTART:
|
||||||
if (attr)
|
if (attr)
|
||||||
{
|
attr = attr->next = (struct rxml_attrib_node*)
|
||||||
struct rxml_attrib_node
|
|
||||||
*new_node = (struct rxml_attrib_node*)
|
|
||||||
calloc(1, sizeof(*attr));
|
calloc(1, sizeof(*attr));
|
||||||
attr = new_node;
|
|
||||||
attr->next = new_node ;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
attr = node->attrib = (struct rxml_attrib_node*)calloc(1, sizeof(*attr));
|
||||||
struct rxml_attrib_node
|
|
||||||
*new_node = (struct rxml_attrib_node*)
|
|
||||||
calloc(1, sizeof(*attr));
|
|
||||||
attr = new_node;
|
|
||||||
|
|
||||||
if (node)
|
|
||||||
node->attrib = new_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr)
|
|
||||||
{
|
|
||||||
if (attr->attrib)
|
if (attr->attrib)
|
||||||
free(attr->attrib);
|
free(attr->attrib);
|
||||||
attr->attrib = strdup(x.attr);
|
attr->attrib = strdup(x.attr);
|
||||||
}
|
|
||||||
|
|
||||||
valptr = buf->val;
|
valptr = buf->val;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user