From a882177f33dbd34dcf893e4ccd71e895795f3c05 Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 2 Jan 2013 15:50:54 +0100 Subject: [PATCH] Fix memory leaks in rxml. --- compat/rxml/Makefile | 2 +- compat/rxml/rxml.c | 7 +++++++ compat/rxml/rxml_test.c | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compat/rxml/Makefile b/compat/rxml/Makefile index 30a4818eba..f3d54f17e1 100644 --- a/compat/rxml/Makefile +++ b/compat/rxml/Makefile @@ -3,7 +3,7 @@ TARGET := rxml SOURCES := $(wildcard *.c) OBJS := $(SOURCES:.c=.o) -CFLAGS += -Wall -pedantic -std=gnu99 -O3 -g +CFLAGS += -DRXML_TEST -Wall -pedantic -std=gnu99 -O0 -g all: $(TARGET) diff --git a/compat/rxml/rxml.c b/compat/rxml/rxml.c index 95dbb6bab2..1eccb8bf59 100644 --- a/compat/rxml/rxml.c +++ b/compat/rxml/rxml.c @@ -21,7 +21,10 @@ #include #include #include "../../boolean.h" + +#ifndef RXML_TEST #include "../../general.h" +#endif struct rxml_document { @@ -53,6 +56,8 @@ static void rxml_free_node(struct rxml_node *node) head = next_attrib; } + free(node->name); + free(node->data); free(node); } @@ -345,7 +350,9 @@ static char *purge_xml_comments(const char *str) rxml_document_t *rxml_load_document(const char *path) { +#ifndef RXML_TEST RARCH_WARN("Using RXML as drop in for libxml2. Behavior might be very buggy.\n"); +#endif char *memory_buffer = NULL; char *new_memory_buffer = NULL; diff --git a/compat/rxml/rxml_test.c b/compat/rxml/rxml_test.c index 047dd34656..0e18c99f1e 100644 --- a/compat/rxml/rxml_test.c +++ b/compat/rxml/rxml_test.c @@ -25,8 +25,8 @@ static void print_siblings(struct rxml_node *node, unsigned level) for (const struct rxml_attrib_node *attrib = node->attrib; attrib; attrib = attrib->next) fprintf(stderr, "%*s Attrib: %s = %s\n", level * 4, "", attrib->attrib, attrib->value); - if (node->childs) - print_siblings(node->childs, level + 1); + if (node->children) + print_siblings(node->children, level + 1); if (node->next) print_siblings(node->next, level);