>From 47315445ed15bbdb6ce90555fd37344c12174aad Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 20 Aug 2014 19:06:48 +0200 Subject: [PATCH 4/7] TESTS: leak_check functions shouldn't be called with NULL context Memory leaks will not be detected if talloc context is NULL. --- src/tests/leak_check.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/leak_check.c b/src/tests/leak_check.c index 06941195db57bd2e710c5f18678efc458fc6c840..bb5698cd80d5b360433d95a6297b740bb5cded87 100644 --- a/src/tests/leak_check.c +++ b/src/tests/leak_check.c @@ -55,6 +55,10 @@ _check_leaks(TALLOC_CTX *ctx, size_t bytes, const char *location) { size_t bytes_allocated; + if (ctx == NULL) { + return false; + } + bytes_allocated = talloc_total_size(ctx); if (bytes_allocated != bytes) { fprintf(stderr, "Leak report for %s:\n", location); @@ -85,6 +89,10 @@ _check_leaks_pop(TALLOC_CTX *ctx, const char *location) TALLOC_CTX *old_ctx; size_t bytes_allocated; + if (ctx == NULL) { + return false; + } + if (snapshot_stack == NULL) { _set_leak_err_msg("%s: trying to pop an empty stack", location); return false; -- 2.1.0