aboutsummaryrefslogtreecommitdiffstats
path: root/storage_xml.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2012-06-05 23:34:13 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2012-06-05 23:34:13 +0100
commit15581c17687d50b36045e4a0276943b7d1aef188 (patch)
tree68567c0f4d48a219bfaf845a3a2e072e78a2c496 /storage_xml.c
parent222b440e3d85e4a45a47f79f017ff53dbcb78276 (diff)
Fixed some small leaks, restored proper read buffer size.
Diffstat (limited to 'storage_xml.c')
-rw-r--r--storage_xml.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/storage_xml.c b/storage_xml.c
index b740dd8f..caaf8a1d 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -67,6 +67,9 @@ static void handle_settings( struct xt_node *node, set_t **head )
{
char *name = xt_find_attr( c, "name" );
+ if( !name )
+ continue;
+
if( strcmp( node->name, "account" ) == 0 )
{
set_t *s = set_find( head, name );
@@ -168,7 +171,7 @@ static const struct xt_handler_entry handlers[] = {
static storage_status_t xml_load_real( irc_t *irc, const char *my_nick, const char *password, xml_pass_st action )
{
struct xml_parsedata xd[1];
- char *fn, buf[204];
+ char *fn, buf[2048];
int fd, st;
struct xt_parser *xp;
struct xt_node *node;
@@ -224,12 +227,14 @@ static storage_status_t xml_load_real( irc_t *irc, const char *my_nick, const ch
}
/* DO NOT call xt_handle() before verifying the password! */
- if( xt_handle( xp, NULL, -1 ) == XT_HANDLED )
+ if( xt_handle( xp, NULL, 1 ) == XT_HANDLED )
ret = STORAGE_OK;
handle_settings( node, &xd->irc->b->set );
error:
+ xt_free( xp );
+ g_free( fn );
return ret;
}
@@ -348,6 +353,16 @@ struct xt_node *xml_generate( irc_t *irc )
return root;
}
+static gboolean xml_generate_nick( gpointer key, gpointer value, gpointer data )
+{
+ struct xt_node *node = xt_new_node( "buddy", NULL, NULL );
+ xt_add_attr( node, "handle", key );
+ xt_add_attr( node, "nick", value );
+ xt_add_child( (struct xt_node *) data, node );
+
+ return FALSE;
+}
+
static storage_status_t xml_save( irc_t *irc, int overwrite )
{
storage_status_t ret = STORAGE_OK;
@@ -402,16 +417,6 @@ finish:
return ret;
}
-static gboolean xml_generate_nick( gpointer key, gpointer value, gpointer data )
-{
- struct xt_node *node = xt_new_node( "buddy", NULL, NULL );
- xt_add_attr( node, "handle", key );
- xt_add_attr( node, "nick", value );
- xt_add_child( (struct xt_node *) data, node );
-
- return FALSE;
-}
-
static storage_status_t xml_remove( const char *nick, const char *password )
{