From 966d9b7893671364b2ae8c04c82c93596390e264 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 13 Jul 2003 17:05:41 +0000 Subject: Fix mem leak and add safety check. 2003-07-13 Christian Persch * lib/ephy-dnd.c: (ephy_dnd_node_list_extract_nodes): Fix mem leak and add safety check. --- lib/ephy-dnd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c index 75fb895d5..4bf9cd2cd 100644 --- a/lib/ephy-dnd.c +++ b/lib/ephy-dnd.c @@ -117,7 +117,7 @@ ephy_dnd_node_list_extract_nodes (const char *node_list) nodes = g_strsplit (node_list, ";", -1); - for (i = 0; nodes[i] != NULL; i = i + 2) + for (i = 0; nodes[i] != NULL && nodes[i+1] != NULL; i = i + 2) { gulong id; EphyNodeDb *db; @@ -131,9 +131,13 @@ ephy_dnd_node_list_extract_nodes (const char *node_list) node = ephy_node_db_get_node_from_id (db, id); g_return_val_if_fail (node != NULL, NULL); - result = g_list_append (result, node); + result = g_list_prepend (result, node); } } + result = g_list_reverse (result); + + g_strfreev (nodes); + return result; } -- cgit v1.2.3