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
Tue Sep 8 22:17:58 UTC 2020


fixeria has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/44/20044/1

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-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200908/70c35286/attachment.htm>


More information about the gerrit-log mailing list