talloc: call return after abort, because an overloaded abort function might not exit
authorStefan Metzmacher <metze@samba.org>
Tue, 14 Jul 2009 09:56:33 +0000 (11:56 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 14 Jul 2009 09:56:33 +0000 (11:56 +0200)
This will be useful in the testsuite,
where we could check if an abort would happen.

metze

lib/talloc/talloc.c

index cfa1cc99a7ae93f9616e214fb23617f94e43237c..4ed48fe59dcbb9b9d5018588f9789cb3287f5d99 100644 (file)
@@ -180,8 +180,10 @@ static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
        if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) { 
                if (tc->flags & TALLOC_FLAG_FREE) {
                        talloc_abort_double_free();
+                       return NULL;
                } else {
                        talloc_abort_unknown_value();
+                       return NULL;
                }
        }
        return tc;
@@ -646,6 +648,7 @@ static inline int _talloc_free(void *ptr)
 
                if (*pool_object_count == 0) {
                        talloc_abort("Pool object count zero!");
+                       return 0;
                }
 
                *pool_object_count -= 1;
@@ -676,6 +679,7 @@ void *_talloc_steal(const void *new_ctx, const void *ptr)
        if (unlikely(talloc_parent_is_no_owner(ptr) &&
                     new_ctx != no_owner_context)) {
                talloc_abort_no_owner_free();
+               return NULL;
        }
 
        if (unlikely(new_ctx == TALLOC_MAGIC_NO_OWNER)) {
@@ -1029,6 +1033,7 @@ int talloc_free(void *ptr)
 
        if (unlikely(talloc_parent_is_no_owner(ptr))) {
                talloc_abort_no_owner_free();
+               return -1;
        }
 
        return _talloc_free(ptr);