ucode: fix memory leak when using ssl context master
authorEric Fahlgren <ericfahlgren@gmail.com>
Mon, 10 Nov 2025 21:18:04 +0000 (13:18 -0800)
committerFelix Fietkau <nbd@nbd.name>
Sat, 31 Jan 2026 13:56:34 +0000 (14:56 +0100)
Check for and free any SSL context when freeing uclient object.

Fixes: https://github.com/openwrt/uclient/issues/11
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
ucode.c

diff --git a/ucode.c b/ucode.c
index fa60806afd7d805e06c271eeeda0fab02bfc66d4..ba65e636117cce61ed266235225e238b43d22e82 100644 (file)
--- a/ucode.c
+++ b/ucode.c
@@ -55,6 +55,8 @@ static void free_uclient(void *ptr)
                return;
 
        ucl = cl->priv;
+       if (ucl->ssl_ctx)
+               ucl->ssl_ops->context_free(ucl->ssl_ctx);
        ucv_array_set(registry, ucl->idx, NULL);
        ucv_array_set(registry, ucl->idx + 1, NULL);
        uclient_free(cl);