summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2019-05-22 13:16:19 +0000
committerAndreas Schneider <asn@cryptomilk.org>2019-06-04 22:13:07 +0000
commit4d095bd052cbe55c05835275eec8d9f2cee7f02e (patch)
tree0d751f8bef3b0b2724d5e266a198e17326a0772a /lib
parente2ee3f8943140df2e52c9778fe43feb544cda977 (diff)
downloadsamba-4d095bd052cbe55c05835275eec8d9f2cee7f02e.tar.gz
lib/pthreadpool: cppcheck: Fix Memory leak
Fixes lib/pthreadpool/tests.c:63: error: memleak: Memory leak: finished <--[cppcheck] Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/pthreadpool/tests.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pthreadpool/tests.c b/lib/pthreadpool/tests.c
index d57754603a2..08cb59ecf59 100644
--- a/lib/pthreadpool/tests.c
+++ b/lib/pthreadpool/tests.c
@@ -60,6 +60,7 @@ static int test_jobs(int num_threads, int num_jobs)
if (ret != 0) {
fprintf(stderr, "pthreadpool_pipe_init failed: %s\n",
strerror(ret));
+ free(finished);
return -1;
}
@@ -68,6 +69,7 @@ static int test_jobs(int num_threads, int num_jobs)
if (ret != 0) {
fprintf(stderr, "pthreadpool_pipe_add_job failed: "
"%s\n", strerror(ret));
+ free(finished);
return -1;
}
}
@@ -78,10 +80,12 @@ static int test_jobs(int num_threads, int num_jobs)
if (ret < 0) {
fprintf(stderr, "pthreadpool_pipe_finished_jobs "
"failed: %s\n", strerror(-ret));
+ free(finished);
return -1;
}
if ((ret != 1) || (jobid >= num_jobs)) {
fprintf(stderr, "invalid job number %d\n", jobid);
+ free(finished);
return -1;
}
finished[jobid] += 1;
@@ -91,6 +95,7 @@ static int test_jobs(int num_threads, int num_jobs)
if (finished[i] != 1) {
fprintf(stderr, "finished[%d] = %d\n",
i, finished[i]);
+ free(finished);
return -1;
}
}
@@ -99,6 +104,7 @@ static int test_jobs(int num_threads, int num_jobs)
if (ret != 0) {
fprintf(stderr, "pthreadpool_pipe_destroy failed: %s\n",
strerror(ret));
+ free(finished);
return -1;
}