From 3cf8a12ab86b9bed33fefc34ea1555946aac5360 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Mon, 13 Jul 2026 16:51:36 +0200 Subject: [PATCH] MT#61856 media_socket: don't exhaust stack With big arrays of INTs, even though the variable type isn't quite heavy, if the pool is for example around 10000...65535 (just because someone needs so many) this loads the stack quite sensible. Just use heap for these calculations. Change-Id: I2ef838a1cb067e6986ba6a6b1c60945d437fabb0 --- daemon/media_socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index f10fa2a91..958cb7651 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -829,7 +829,7 @@ static void __append_free_ports_to_int(struct intf_spec *spec) { return; } - int port_values[ports_amount]; + unsigned int *port_values = g_new(unsigned int, ports_amount); /* create an array to store the initial values within the range */ for (int i = 0; i < ports_amount; i++) @@ -854,6 +854,8 @@ static void __append_free_ports_to_int(struct intf_spec *spec) { port_values[j] = port_values[count - 1]; count--; } + + g_free(port_values); } // called during single-threaded startup only static void __add_intf_rr_1(struct logical_intf *lif, str *name_base, sockfamily_t *fam) {