From f059818d74bbf856ccb0674555c9c73f0c6e93e5 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 5 Apr 2007 12:33:12 +0000 Subject: Squash memory leak svn path=/trunk/netsurf/; revision=3235 --- content/urldb.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/content/urldb.c b/content/urldb.c index 457dc7a90..e127db8b4 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -2054,19 +2054,21 @@ struct search_node *urldb_search_remove(struct search_node *root, const struct host_part *data) { static struct search_node *last, *deleted; + int c; assert(root && data); - if (root != &empty) { - int c = urldb_search_match_host(root->data, data); + if (root == &empty) + return root; - last = root; - if (c > 0) { - root->left = urldb_search_remove(root->left, data); - } else { - deleted = root; - root->right = urldb_search_remove(root->right, data); - } + c = urldb_search_match_host(root->data, data); + + last = root; + if (c > 0) { + root->left = urldb_search_remove(root->left, data); + } else { + deleted = root; + root->right = urldb_search_remove(root->right, data); } if (root == last) { @@ -2076,6 +2078,7 @@ struct search_node *urldb_search_remove(struct search_node *root, deleted->data = last->data; deleted = ∅ root = root->right; + free(last); } } else { if (root->left->level < root->level - 1 || -- cgit v1.2.3