summaryrefslogtreecommitdiffstats
path: root/src
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:51:31 +0200
commit24000ed5b08499b49595436b8a3b348fcd4012de (patch)
tree2d8f8c43536fbe368b6cbc3318210f0ca1c453de /src
parent12e7e87ccbae0d5c2f338cd019ca51556cbcd3ae (diff)
downloadsssd-24000ed5b08499b49595436b8a3b348fcd4012de.tar.gz
sssd-24000ed5b08499b49595436b8a3b348fcd4012de.tar.xz
sssd-24000ed5b08499b49595436b8a3b348fcd4012de.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>
Diffstat (limited to 'src')
-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;