Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/3] voicecall: Fix memory leak
@ 2024-02-27 15:33 Denis Kenzior
  2024-02-27 15:33 ` [PATCH 2/3] voicecall: Fix use after free Denis Kenzior
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Denis Kenzior @ 2024-02-27 15:33 UTC (permalink / raw)
  To: ofono; +Cc: Denis Kenzior

'number' is obtained using g_key_file_get_string (which returns a newly
allocated string), but is never freed.
---
 src/voicecall.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index d10fe15a423d..f979c46fe132 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -3462,7 +3462,7 @@ static void emulator_dial_callback(const struct ofono_error *error, void *data)
 	struct ofono_voicecall *vc = data;
 	gboolean need_to_emit;
 	struct voicecall *v;
-	const char *number;
+	char *number;
 	GError *err = NULL;
 
 	number = g_key_file_get_string(vc->settings, SETTINGS_GROUP,
@@ -3484,6 +3484,8 @@ static void emulator_dial_callback(const struct ofono_error *error, void *data)
 
 	if (need_to_emit)
 		voicecalls_emit_call_added(vc, v);
+
+	g_free(number);
 }
 
 static void emulator_dial(struct ofono_emulator *em, struct ofono_voicecall *vc,
@@ -3585,7 +3587,7 @@ static void emulator_bldn_cb(struct ofono_emulator *em,
 			struct ofono_emulator_request *req, void *userdata)
 {
 	struct ofono_voicecall *vc = userdata;
-	const char *number;
+	char *number = NULL;
 	struct ofono_error result;
 	GError *error = NULL;
 
@@ -3608,6 +3610,8 @@ fail:
 		result.type = OFONO_ERROR_TYPE_FAILURE;
 		ofono_emulator_send_final(em, &result);
 	};
+
+	g_free(number);
 }
 
 static void emulator_hfp_watch(struct ofono_atom *atom,
-- 
2.43.0


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

end of thread, other threads:[~2024-02-27 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 15:33 [PATCH 1/3] voicecall: Fix memory leak Denis Kenzior
2024-02-27 15:33 ` [PATCH 2/3] voicecall: Fix use after free Denis Kenzior
2024-02-27 15:33 ` [PATCH 3/3] lte: Fix invalid cleanup Denis Kenzior
2024-02-27 17:50 ` [PATCH 1/3] voicecall: Fix memory leak patchwork-bot+ofono

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