From 0f91e4e18db5f896c94f98e84f572568d0b1c3e4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 31 Mar 2015 09:34:54 +0200 Subject: [PATCH] lib: Fix a few CIDs for Resource Leak Signed-off-by: Volker Lendecke Reviewed-by: Michael Adam --- lib/util/tests/file.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/util/tests/file.c b/lib/util/tests/file.c index 85080818de0..f349c214f08 100644 --- a/lib/util/tests/file.c +++ b/lib/util/tests/file.c @@ -66,6 +66,7 @@ static bool test_afdgets(struct torture_context *tctx) int fd; char *line; TALLOC_CTX *mem_ctx = tctx; + bool ret = false; torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA, strlen(TEST_DATA)), @@ -76,18 +77,22 @@ static bool test_afdgets(struct torture_context *tctx) torture_assert(tctx, fd != -1, "opening file"); line = afdgets(fd, mem_ctx, 8); - torture_assert(tctx, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch"); + torture_assert_goto(tctx, strcmp(line, TEST_LINE1) == 0, ret, done, + "line 1 mismatch"); line = afdgets(fd, mem_ctx, 8); - torture_assert(tctx, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch"); + torture_assert_goto(tctx, strcmp(line, TEST_LINE2) == 0, ret, done, + "line 2 mismatch"); line = afdgets(fd, mem_ctx, 8); - torture_assert(tctx, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch"); - + torture_assert_goto(tctx, strcmp(line, TEST_LINE3) == 0, ret, done, + "line 3 mismatch"); + ret = true; +done: close(fd); unlink(TEST_FILENAME); - return true; + return ret; } struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx) -- 2.11.4.GIT