summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-08-20 19:06:48 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-08-22 11:00:20 +0200
commitd35cd0198a5e60795b6766a90d536be5b0b7dacb (patch)
tree4ea266f8cb429430e8ffa0cdaeb5db8c18784690
parent5d298e5f07cdc72710e326cd70fe55501fb0aa73 (diff)
downloadsssd-d35cd0198a5e60795b6766a90d536be5b0b7dacb.tar.gz
sssd-d35cd0198a5e60795b6766a90d536be5b0b7dacb.tar.xz
sssd-d35cd0198a5e60795b6766a90d536be5b0b7dacb.zip
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 <jhrozek@redhat.com> (cherry picked from commit 24000ed5b08499b49595436b8a3b348fcd4012de)
-rw-r--r--src/tests/leak_check.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/tests/leak_check.c b/src/tests/leak_check.c
index 06941195d..bb5698cd8 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;