]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Use free() for hyperscan-allocated buffers in lua_hyperscan
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 7 Jan 2026 09:09:48 +0000 (09:09 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 7 Jan 2026 09:09:48 +0000 (09:09 +0000)
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.

src/lua/lua_hyperscan.cxx

index d85d2d358e5439e7d60a320b2d74ac5a75bde802..d486490b779c719c04c6784dc82678c0f3a44d1c 100644 (file)
@@ -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;
 }