mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 22:41:10 +01:00
Three accumulator vectors -- ops, sub_blobs, transform_stack -- can enter error state via failed push_or_fail() under failing-malloc. Once in error state, resize(0) short-circuits at the in_error() guard in alloc() and leaves length unchanged. In hb_gpu_paint_clear that means the next iteration's clear walks the stale entries again. For sub_blobs this is a double-destroy: the blob pointers were already freed in the previous clear, and hb_blob_destroy reads the dead ref_count field -- heap-use-after-free. Fix by calling vector.reset(), which clears the error state before resizing to 0. Matches the pattern hb_gpu_draw_clear already uses for draw->curves. Found by oss-fuzz/CIFuzz on hb-gpu-fuzzer; minimized testcase added to the fuzz corpus. Assisted-by: Claude <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: