Squash memory leak

svn path=/trunk/netsurf/; revision=3235
This commit is contained in:
John Mark Bell 2007-04-05 12:33:12 +00:00
parent 6eba75b1c6
commit f059818d74

View File

@ -2054,19 +2054,21 @@ struct search_node *urldb_search_remove(struct search_node *root,
const struct host_part *data) const struct host_part *data)
{ {
static struct search_node *last, *deleted; static struct search_node *last, *deleted;
int c;
assert(root && data); assert(root && data);
if (root != &empty) { if (root == &empty)
int c = urldb_search_match_host(root->data, data); return root;
last = root; c = urldb_search_match_host(root->data, data);
if (c > 0) {
root->left = urldb_search_remove(root->left, data); last = root;
} else { if (c > 0) {
deleted = root; root->left = urldb_search_remove(root->left, data);
root->right = urldb_search_remove(root->right, data); } else {
} deleted = root;
root->right = urldb_search_remove(root->right, data);
} }
if (root == last) { if (root == last) {
@ -2076,6 +2078,7 @@ struct search_node *urldb_search_remove(struct search_node *root,
deleted->data = last->data; deleted->data = last->data;
deleted = ∅ deleted = ∅
root = root->right; root = root->right;
free(last);
} }
} else { } else {
if (root->left->level < root->level - 1 || if (root->left->level < root->level - 1 ||