Change in osmocom-bb[master]: mobile/sms: Fix memory leak in case the storage can not be opened

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/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Tue Jun 5 20:21:58 UTC 2018


Holger Freyther has submitted this change and it was merged. ( https://gerrit.osmocom.org/9417 )

Change subject: mobile/sms: Fix memory leak in case the storage can not be opened
......................................................................

mobile/sms: Fix memory leak in case the storage can not be opened

Before jumping to the failure handling code free the sms_file.

Change-Id: Ifce2bc130fe3a5bd49ad457ee61002952dd496ba
---
M src/host/layer23/src/mobile/gsm411_sms.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/src/host/layer23/src/mobile/gsm411_sms.c b/src/host/layer23/src/mobile/gsm411_sms.c
index 9090697..3eca48a 100644
--- a/src/host/layer23/src/mobile/gsm411_sms.c
+++ b/src/host/layer23/src/mobile/gsm411_sms.c
@@ -213,8 +213,10 @@
 	snprintf(sms_file, len, "%s/%s", home, osmocomsms);
 
 	fp = fopen(sms_file, "a");
-	if (!fp)
+	if (!fp) {
+		talloc_free(sms_file);
 		goto fail;
+	}
 	fprintf(fp, "[SMS from %s]\n%s\n", gsms->address, gsms->text);
 	fclose(fp);
 

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifce2bc130fe3a5bd49ad457ee61002952dd496ba
Gerrit-Change-Number: 9417
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180605/b4469f1b/attachment.htm>


More information about the gerrit-log mailing list