]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Fix allocator mismatches in libucl
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 1 Nov 2025 22:14:07 +0000 (22:14 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 1 Nov 2025 22:14:07 +0000 (22:14 +0000)
commit8e3bf5b9553b29ce4be96f82743f3b76657edd44
treeb75ee3bf33c979f5cef370043fcd44ccdd29cd9d
parent57fb33ebfb502a4744873dbcd0e820408b68122f
[Fix] Fix allocator mismatches in libucl

Resolve crashes caused by mixing jemalloc and system malloc allocators
in libucl. The issue occurred when memory allocated with one allocator
(e.g., strdup using system malloc) was freed with another (e.g., jemalloc's
free), causing segmentation faults.

Changes:
- Add UCL_REALLOC and UCL_STRDUP macros to ucl.h for consistent allocation
- Replace all strdup/malloc/realloc/free calls with UCL_* macros in:
  - Variable and macro registration (ucl_parser.c)
  - Parser state management (ucl_util.c)
  - Object copying and trash stack operations (ucl_util.c)
  - URL fetching - fix critical bug where malloc'd buffers were freed
    with ucl_munmap (munmap) instead of free (ucl_util.c)

This ensures all memory operations use the same allocator throughout libucl,
preventing allocator mismatch crashes on systems using jemalloc.
contrib/libucl/ucl.h
contrib/libucl/ucl_parser.c
contrib/libucl/ucl_util.c