From 24000ed5b08499b49595436b8a3b348fcd4012de Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 20 Aug 2014 19:06:48 +0200 Subject: TESTS: leak_check functions shouldn't be called with NULL context Memory leaks will not be detected if talloc context is NULL. Reviewed-by: Jakub Hrozek --- src/tests/leak_check.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/tests/leak_check.c b/src/tests/leak_check.c index 06941195..bb5698cd 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; -- cgit