talloc: added a test for the use after free Rusty found
authorAndrew Tridgell <tridge@samba.org>
Wed, 22 Dec 2010 04:29:37 +0000 (15:29 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 5 Jan 2011 05:37:07 +0000 (06:37 +0100)
lib/talloc/testsuite.c

index 0026931d260cb4756ef413e3c0766a5b3fbf2fed..ee6256b8e1b7b829680ab74ce20376f3dc7e6d4b 100644 (file)
@@ -1167,6 +1167,21 @@ static bool test_free_ref_null_context(void)
        return true;
 }
 
+static bool test_rusty(void)
+{
+       void *root;
+       const char *p1;
+
+       talloc_enable_null_tracking();
+       root = talloc_new(NULL);
+       p1 = talloc_strdup(root, "foo");
+       talloc_increase_ref_count(p1);
+       talloc_report_full(root, stdout);
+       talloc_free(root);
+       return true;
+}
+
+
 static void test_reset(void)
 {
        talloc_set_log_fn(test_log_stdout);
@@ -1221,6 +1236,8 @@ bool torture_local_talloc(struct torture_context *tctx)
        ret &= test_pool();
        test_reset();
        ret &= test_free_ref_null_context();
+       test_reset();
+       ret &= test_rusty();
 
        if (ret) {
                test_reset();