From 9cedc32c3a94b9ef45c9b7b2231d67ea4d14e476 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Fri, 31 May 2024 04:39:32 +0200 Subject: [PATCH] Fix memory leak in egg_string_unicodesup_desurrogate() --- 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