diff mbox series

[1/3] voicecall: Fix memory leak

Message ID 20240227153314.1469536-1-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 0695b4df2ca4936b1a7e063f88dedcd05cffaf52
Headers show
Series [1/3] voicecall: Fix memory leak | expand

Commit Message

Denis Kenzior Feb. 27, 2024, 3:33 p.m. UTC
'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(-)

Comments

patchwork-bot+ofono@kernel.org Feb. 27, 2024, 5:50 p.m. UTC | #1
Hello:

This series was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:

On Tue, 27 Feb 2024 09:33:02 -0600 you wrote:
> '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(-)

Here is the summary with links:
  - [1/3] voicecall: Fix memory leak
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=0695b4df2ca4
  - [2/3] voicecall: Fix use after free
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=a46dff5b2476
  - [3/3] lte: Fix invalid cleanup
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=6bf0a2541d43

You are awesome, thank you!
diff mbox series

Patch

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,