From f427a975b8a4b2aee2ba0c37e28d6ebbf84c67fb Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Thu, 29 Nov 2018 13:22:59 +0100 Subject: [PATCH] tests: Fix a clang possible memory leak warning clang was reporting a possible memory leak after mkdtemp() call, which was a false positive, since mkdtemp() returns the same pointer provided as the parameter, in case of success. This changes the code so that the static analyser don't get confused. Found by csbuild runner. Signed-off-by: Anderson Toshiyuki Sasaki Reviewed-by: Andreas Schneider --- tests/torture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/torture.c b/tests/torture.c index 88387edb..3500cd50 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -805,11 +805,11 @@ char *torture_make_temp_dir(const char *template) new_dir = mkdtemp(template_copy); if (new_dir == NULL) { - free(template_copy); + SAFE_FREE(template_copy); } end: - return new_dir; + return template_copy; } char *torture_create_temp_file(const char *template)