Change in libosmocore[master]: logging: fix memleak in log_target_create_file()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Wed Sep 9 11:40:46 UTC 2020


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20044 )

Change subject: logging: fix memleak in log_target_create_file()
......................................................................

logging: fix memleak in log_target_create_file()

Change-Id: If16d8c6417698bbb5cf87716f9507c7256aeaecb
---
M src/logging.c
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, approved



diff --git a/src/logging.c b/src/logging.c
index 80ff72c..db04cf7 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -915,8 +915,10 @@
 
 	target->type = LOG_TGT_TYPE_FILE;
 	target->tgt_file.out = fopen(fname, "a");
-	if (!target->tgt_file.out)
+	if (!target->tgt_file.out) {
+		log_target_destroy(target);
 		return NULL;
+	}
 
 	target->output = _file_output;
 
@@ -966,6 +968,8 @@
 #if (!EMBEDDED)
 	switch (target->type) {
 	case LOG_TGT_TYPE_FILE:
+		if (target->tgt_file.out == NULL)
+			break;
 		fclose(target->tgt_file.out);
 		target->tgt_file.out = NULL;
 		break;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20044
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If16d8c6417698bbb5cf87716f9507c7256aeaecb
Gerrit-Change-Number: 20044
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200909/8d07d4ba/attachment.htm>


More information about the gerrit-log mailing list