talloc: when we enable NULL tracking, reparent the autofree context
authorAndrew Tridgell <tridge@samba.org>
Tue, 15 Sep 2009 16:43:27 +0000 (09:43 -0700)
committerAndrew Tridgell <tridge@samba.org>
Tue, 15 Sep 2009 16:43:27 +0000 (09:43 -0700)
If NULL tracking is enabled after the autofree context is initialised
then autofree ends up separate from the null_context. This means that
talloc_report_full() doesn't report the autofree context. Fix this by
reparenting the autofree context when we create the null_context.

lib/talloc/talloc.c

index 2709741dfcbd01adbe611e77a25383e6cadb6ace..478767c95513062a466998c88198d8402e7e3a7c 100644 (file)
@@ -1468,6 +1468,9 @@ void talloc_enable_null_tracking(void)
 {
        if (null_context == NULL) {
                null_context = _talloc_named_const(NULL, 0, "null_context");
+               if (autofree_context != NULL) {
+                       talloc_reparent(NULL, null_context, autofree_context);
+               }
        }
 }