From 9068233364b28ca9c6840aca7fbd30ecdfa0ac33 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:00:54 +0200 Subject: [PATCH] Fix memory leak in egg_string_unicodesup_desurrogate() Patch by: michaelortmann --- src/tcl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tcl.c b/src/tcl.c index 5015fd5b5..71fe6d9be 100644 --- a/src/tcl.c +++ b/src/tcl.c @@ -767,6 +767,7 @@ Tcl_Obj *egg_string_unicodesup_desurrogate(const char *oldstr, int len) { int stridx = 0, bufidx = 0; char *buf = nmalloc(len); + Tcl_Obj *o; while (stridx < len) { uint32_t low, high; @@ -787,7 +788,10 @@ Tcl_Obj *egg_string_unicodesup_desurrogate(const char *oldstr, int len) } } } - return Tcl_NewStringObj(buf, bufidx); + + o = Tcl_NewStringObj(buf, bufidx); + nfree(buf); + return o; } /* C function called for ::egg_tcl_tolower/toupper/totitle