]> git.kaiwu.me - njs.git/commitdiff
Memory pool: junk filling only in debug builds
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 8 Sep 2026 22:46:52 +0000 (15:46 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 18 Sep 2026 20:42:16 +0000 (13:42 -0700)
Previously, every freed chunk was overwritten with 0x5A in all builds,
adding a memset to each njs_mp_free() call.

The fix is to keep the junk filling under NJS_DEBUG.  Release builds no
longer poison freed chunks; nothing ever inspected the pattern.

src/njs_mp.c

index f1d464a326a535cd293af6e7bce71c1e1a59f124..83fb76dbf90ef09b13161b17787fa2641bd82cb4 100644 (file)
@@ -120,9 +120,15 @@ struct njs_mp_s {
     map[chunk / 8] &= ~(0x80 >> (chunk & 7))
 
 
+#if (NJS_DEBUG)
 #define njs_mp_free_junk(p, size)                                             \
     njs_memset((p), 0x5A, size)
 
+#else
+#define njs_mp_free_junk(p, size)
+
+#endif
+
 
 #define njs_is_power_of_two(value)                                            \
     ((((value) - 1) & (value)) == 0)