Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] lib/tst_memutils.c: Fix resource leak
@ 2022-02-11 15:27 Bogdan Lezhepekov via ltp
  2022-02-15 13:04 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2022-02-11 15:27 UTC (permalink / raw)
  To: ltp

File descriptor was not closed properly
before return.

Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
 lib/tst_memutils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index 4a4974761..2e6d7d5fd 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -122,7 +122,10 @@ static int write_score(const char *path, int score)
 		return 1;
 
 	if (fprintf(f, "%d", score) <= 0)
+	{
+		fclose(f);
 		return 1;
+	}
 
 	if (fclose(f))
 		return 1;
-- 
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-15 13:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-11 15:27 [LTP] [PATCH v1] lib/tst_memutils.c: Fix resource leak Bogdan Lezhepekov via ltp
2022-02-15 13:04 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox