Mercurial > pidgin
changeset 7075:4e5654931401
[gaim-migrate @ 7640]
this is how this function is supposed to behave
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 30 Sep 2003 17:14:14 +0000 |
parents | c6807437dcd7 |
children | 9f1a6c97108d |
files | src/protocols/jabber/xmlnode.c |
diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/jabber/xmlnode.c Tue Sep 30 16:36:00 2003 +0000 +++ b/src/protocols/jabber/xmlnode.c Tue Sep 30 17:14:14 2003 +0000 @@ -210,21 +210,25 @@ char * xmlnode_get_data(xmlnode *node) { - GString *str; - char *ret; + GString *str = NULL; + char *ret = NULL; xmlnode *c; g_return_val_if_fail(node != NULL, NULL); - str = g_string_new(""); for(c = node->child; c; c = c->next) { - if(c->type == NODE_TYPE_DATA) + if(c->type == NODE_TYPE_DATA) { + if(!str) + str = g_string_new(""); str = g_string_append_len(str, c->data, c->data_sz); + } } - ret = str->str; - g_string_free(str, FALSE); + if(str) { + ret = str->str; + g_string_free(str, FALSE); + } return ret; }