mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
clear() called resize(0) which calls alloc(0), but alloc() bails immediately when the vector is in error state, so length was never zeroed. Under failing-malloc, a vector could enter error state from a failed push, making all subsequent clear() calls silently fail, leaving stale pointers. This caused a heap-use-after-free in hb_raster_paint_destroy(): render() released surfaces to surface_cache then called surface_stack.clear() which silently failed, so destroy() iterated the stale surface_stack pointers and double-freed images already in surface_cache. Fixes https://oss-fuzz.com/testcase?key=5078588000108544 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
To build the fuzzers with libFuzzer to perform actual fuzzing, build with:
CXX=clang++ CXXFLAGS="-fsanitize=address,fuzzer-no-link" meson fuzzbuild --default-library=static -Dfuzzer_ldflags="-fsanitize=address,fuzzer"
ninja -Cfuzzbuild
Then, run the fuzzer like this:
fuzzbuild/test/fuzzing/hb-{shape,raster,vector,subset,set}-fuzzer [-max_len=2048] [CORPUS_DIR]
Where max_len specifies the maximal length of font files to handle. The smaller the faster.
For more details consult the following locations: