diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-04-20 15:30:57 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-04-20 15:50:27 +1000 |
commit | 45be1c7ba4382d85c742a241687bbc6d5a2ebd8c (patch) | |
tree | c9fabbf2b9566bad59f7d87d7461d7cff78396fa /lib/talloc/talloc.c | |
parent | 773a8afbba27a5e2e48577100f3ca9873b506615 (diff) | |
download | samba-45be1c7ba4382d85c742a241687bbc6d5a2ebd8c.tar.gz samba-45be1c7ba4382d85c742a241687bbc6d5a2ebd8c.tar.bz2 samba-45be1c7ba4382d85c742a241687bbc6d5a2ebd8c.zip |
talloc: there is no ambiguity when freeing a ptr with a null parent
when a ptr has a single reference and a NULL parent, then
talloc_free(ptr) is not ambiguous, as the caller could not have done a
talloc_free(NULL) to free the memory
Pair-Programmed-With: Rusty Russell <rusty@samba.org>
Diffstat (limited to 'lib/talloc/talloc.c')
-rw-r--r-- | lib/talloc/talloc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index d3b5565fe2..bd364ed51b 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -1128,6 +1128,13 @@ _PUBLIC_ int _talloc_free(void *ptr, const char *location) if (unlikely(tc->refs != NULL)) { struct talloc_reference_handle *h; + if (talloc_parent(ptr) == null_context && tc->refs->next == NULL) { + /* in this case we do know which parent should + get this pointer, as there is really only + one parent */ + return talloc_unlink(null_context, ptr); + } + talloc_log("ERROR: talloc_free with references at %s\n", location); |