diff options
author | Jeremy Allison <jra@samba.org> | 2015-03-05 12:48:47 -0800 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2015-03-24 04:51:14 +0100 |
commit | 599ca101656d1111ff7aec32d1a813ef434d9977 (patch) | |
tree | 356665516f4126b0ce3897b30e1b28c73f4309cc /lib | |
parent | bb97c5e20c7ad3c6ec6e6b46f73ceb5636bc478d (diff) | |
download | samba-599ca101656d1111ff7aec32d1a813ef434d9977.tar.gz |
lib: talloc: Fix bug when calling a destructor.
If the destructor itself calls talloc_set_destructor()
and returns -1, the new destructor set is overwritten
by talloc.
Dectect that and leave the new destructor in place.
Needed for bug:
https://bugzilla.samba.org/show_bug.cgi?id=11144
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/talloc/talloc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index fa56ea56780..1ccb039ff74 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -991,7 +991,13 @@ static inline int _talloc_free_internal(void *ptr, const char *location) } tc->destructor = (talloc_destructor_t)-1; if (d(ptr) == -1) { - tc->destructor = d; + /* + * Only replace the destructor pointer if + * calling the destructor didn't modify it. + */ + if (tc->destructor == (talloc_destructor_t)-1) { + tc->destructor = d; + } return -1; } tc->destructor = NULL; |