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 10:55:02 +0200
commit103f2f305ba073f9e9399cac10eefd3685bb291c (patch)
tree32b5ce4b0fbfb3b52cff72cb7e73e579d3db4925
parentd111a01626bfe1ec468a2f6e01e6a237286481d8 (diff)
downloadsssd-103f2f305ba073f9e9399cac10eefd3685bb291c.tar.gz
sssd-103f2f305ba073f9e9399cac10eefd3685bb291c.tar.xz
sssd-103f2f305ba073f9e9399cac10eefd3685bb291c.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;