xmlGetProp appears to return malloced memory. Thus we must free it.

2000-05-16  Christopher James Lahey  <clahey@helixcode.com>

	* e-xml-utils.c: xmlGetProp appears to return malloced memory.
	Thus we must free it.

svn path=/trunk/; revision=3087
This commit is contained in:
Christopher James Lahey
2000-05-16 12:16:16 +00:00
committed by Chris Lahey
parent f6c356b116
commit 277df4a98d
3 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2000-05-16 Christopher James Lahey <clahey@helixcode.com>
* e-xml-utils.c: xmlGetProp appears to return malloced memory.
Thus we must free it.
2000-05-15 Ettore Perazzoli <ettore@helixcode.com> 2000-05-15 Ettore Perazzoli <ettore@helixcode.com>
* e-util.c (e_free_string_list): New function. * e-util.c (e_free_string_list): New function.

View File

@ -23,6 +23,7 @@
#include <locale.h> #include <locale.h>
#include "e-xml-utils.h" #include "e-xml-utils.h"
#include <gnome-xml/parser.h> #include <gnome-xml/parser.h>
#include <gnome-xml/xmlmemory.h>
xmlNode *e_xml_get_child_by_name(xmlNode *parent, const xmlChar *child_name) xmlNode *e_xml_get_child_by_name(xmlNode *parent, const xmlChar *child_name)
@ -74,15 +75,17 @@ int
e_xml_get_integer_prop_by_name(xmlNode *parent, const xmlChar *prop_name) e_xml_get_integer_prop_by_name(xmlNode *parent, const xmlChar *prop_name)
{ {
xmlChar *prop; xmlChar *prop;
int ret_val = 0;
g_return_val_if_fail (parent != NULL, 0); g_return_val_if_fail (parent != NULL, 0);
g_return_val_if_fail (prop_name != NULL, 0); g_return_val_if_fail (prop_name != NULL, 0);
prop = xmlGetProp(parent, prop_name); prop = xmlGetProp(parent, prop_name);
if (prop) if (prop) {
return atoi(prop); ret_val = atoi(prop);
else xmlFree(prop);
return 0; }
return ret_val;
} }
void void

View File

@ -23,6 +23,7 @@
#include <locale.h> #include <locale.h>
#include "e-xml-utils.h" #include "e-xml-utils.h"
#include <gnome-xml/parser.h> #include <gnome-xml/parser.h>
#include <gnome-xml/xmlmemory.h>
xmlNode *e_xml_get_child_by_name(xmlNode *parent, const xmlChar *child_name) xmlNode *e_xml_get_child_by_name(xmlNode *parent, const xmlChar *child_name)
@ -74,15 +75,17 @@ int
e_xml_get_integer_prop_by_name(xmlNode *parent, const xmlChar *prop_name) e_xml_get_integer_prop_by_name(xmlNode *parent, const xmlChar *prop_name)
{ {
xmlChar *prop; xmlChar *prop;
int ret_val = 0;
g_return_val_if_fail (parent != NULL, 0); g_return_val_if_fail (parent != NULL, 0);
g_return_val_if_fail (prop_name != NULL, 0); g_return_val_if_fail (prop_name != NULL, 0);
prop = xmlGetProp(parent, prop_name); prop = xmlGetProp(parent, prop_name);
if (prop) if (prop) {
return atoi(prop); ret_val = atoi(prop);
else xmlFree(prop);
return 0; }
return ret_val;
} }
void void