From: Vsevolod Stakhov Date: Wed, 7 Jan 2026 09:09:48 +0000 (+0000) Subject: [Fix] Use free() for hyperscan-allocated buffers in lua_hyperscan X-Git-Tag: 4.0.0~208^2~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c263d99cd34ae1efae2dc88852827645c985fcc;p=thirdparty%2Frspamd.git [Fix] Use free() for hyperscan-allocated buffers in lua_hyperscan hs_serialize_database() uses the standard C allocator, so the returned buffer must be freed with free(), not g_free(). Mixing allocators causes memory corruption when hiredis is configured to use glib. --- diff --git a/src/lua/lua_hyperscan.cxx b/src/lua/lua_hyperscan.cxx index d85d2d358e..d486490b77 100644 --- a/src/lua/lua_hyperscan.cxx +++ b/src/lua/lua_hyperscan.cxx @@ -250,7 +250,7 @@ lua_hyperscan_serialize(lua_State *L) hs_platform_info_t plt; err = hs_populate_platform(&plt); if (err != HS_SUCCESS) { - g_free(ser_bytes); + free(ser_bytes); lua_pushnil(L); lua_pushstring(L, "failed to get platform info"); return 2; @@ -349,8 +349,8 @@ lua_hyperscan_serialize(lua_State *L) /* Copy serialized database */ memcpy(p, ser_bytes, ser_size); - /* Free hyperscan-allocated buffer */ - g_free(ser_bytes); + /* Free hyperscan-allocated buffer (use free(), not g_free()) */ + free(ser_bytes); return 1; }