[asterisk-commits] eliel: branch eliel/data_retrieval r189305 - /team/eliel/data_retrieval/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 20 09:23:27 CDT 2009
Author: eliel
Date: Mon Apr 20 09:23:19 2009
New Revision: 189305
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=189305
Log:
Free allocated memory on error.
Modified:
team/eliel/data_retrieval/main/data.c
Modified: team/eliel/data_retrieval/main/data.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/data_retrieval/main/data.c?view=diff&rev=189305&r1=189304&r2=189305
==============================================================================
--- team/eliel/data_retrieval/main/data.c (original)
+++ team/eliel/data_retrieval/main/data.c Mon Apr 20 09:23:19 2009
@@ -420,7 +420,7 @@
static struct ast_xml_node *data_xml_node_create(struct ast_data_node *root,
const char *path)
{
- struct ast_xml_node *node, *child, *root_node = (struct ast_xml_node *) root;
+ struct ast_xml_node *node, *child, *first = NULL, *root_node = (struct ast_xml_node *) root;
char *rpath, *node_name;
if (!root_node || !path) {
@@ -454,8 +454,13 @@
child = ast_xml_new_node(node_name);
if (!child) {
ast_log(LOG_ERROR, "Unable to allocate node '%s'\n", node_name);
- /* XXX: free already allocated memory. */
+ /* if there was a child node added, free it. */
+ ast_xml_free_node(first);
return NULL;
+ }
+ /* save first created and added child node to free it if something goes wrong. */
+ if (!first) {
+ first = child;
}
ast_xml_add_child(node, child);
}
More information about the asterisk-commits
mailing list