/dev/tomkiewicz/new-smileys: 27c5683767c8: MemoryPool: fix inval...

Tomasz Wasilczyk twasilczyk at pidgin.im
Wed Apr 2 15:33:23 EDT 2014


Changeset: 27c5683767c8682f1bdd318d081631f9c6823727
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-02 21:33 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/27c5683767c8

Description:

MemoryPool: fix invalid read, Trie: test tweaks

diffstat:

 libpurple/memorypool.c      |   1 +
 libpurple/tests/test_trie.c |  27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diffs (62 lines):

diff --git a/libpurple/memorypool.c b/libpurple/memorypool.c
--- a/libpurple/memorypool.c
+++ b/libpurple/memorypool.c
@@ -160,6 +160,7 @@ purple_memory_pool_cleanup_impl(PurpleMe
 
 	blk = priv->first_block;
 	priv->first_block = NULL;
+	priv->last_block = NULL;
 	while (blk) {
 		PurpleMemoryPoolBlock *next = blk->next;
 		g_free(blk);
diff --git a/libpurple/tests/test_trie.c b/libpurple/tests/test_trie.c
--- a/libpurple/tests/test_trie.c
+++ b/libpurple/tests/test_trie.c
@@ -23,6 +23,7 @@ START_TEST(test_trie_replace)
 	gchar *out;
 
 	trie = purple_trie_new();
+	purple_trie_set_reset_on_match(trie, FALSE);
 
 	purple_trie_add(trie, "test", (gpointer)0x1001);
 	purple_trie_add(trie, "testing", (gpointer)0x1002);
@@ -154,6 +155,31 @@ START_TEST(test_trie_multi_replace)
 }
 END_TEST
 
+START_TEST(test_trie_remove)
+{
+	PurpleTrie *trie;
+	const gchar *in;
+	gchar *out;
+
+	trie = purple_trie_new();
+
+	purple_trie_add(trie, "alice", (gpointer)0x6001);
+	purple_trie_add(trie, "bob", (gpointer)0x6002);
+	purple_trie_add(trie, "cherry", (gpointer)0x6003);
+
+	purple_trie_remove(trie, "bob");
+
+	in = "alice bob cherry";
+
+	out = purple_trie_replace(trie, in, test_trie_replace_cb, (gpointer)6);
+
+	assert_string_equal("[6:6001] bob [6:6003]", out);
+
+	g_object_unref(trie);
+	g_free(out);
+}
+END_TEST
+
 Suite *
 purple_trie_suite(void)
 {
@@ -165,6 +191,7 @@ purple_trie_suite(void)
 	tcase_add_test(tc, test_trie_replace_inner);
 	tcase_add_test(tc, test_trie_replace_empty);
 	tcase_add_test(tc, test_trie_multi_replace);
+	tcase_add_test(tc, test_trie_remove);
 
 	suite_add_tcase(s, tc);
 



More information about the Commits mailing list