diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/talloc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c index 12b21d21e6..131edfcb81 100644 --- a/source4/lib/talloc.c +++ b/source4/lib/talloc.c @@ -441,7 +441,7 @@ int talloc_free(void *ptr) if (tc->refs) { talloc_reference_destructor(tc->refs); - return 0; + return -1; } if (tc->destructor) { @@ -469,11 +469,13 @@ int talloc_free(void *ptr) struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); if (p) new_parent = p+1; } - if (new_parent == null_context) { - struct talloc_chunk *p = talloc_parent_chunk(ptr); - if (p) new_parent = p+1; + if (talloc_free(child) == -1) { + if (new_parent == null_context) { + struct talloc_chunk *p = talloc_parent_chunk(ptr); + if (p) new_parent = p+1; + } + talloc_steal(new_parent, child); } - talloc_free(talloc_steal(new_parent, child)); } if (tc->parent) { |