mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 22:41:10 +01:00
[gpu] Use vector.reset() not resize(0) in hb_gpu_paint_clear
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>
This commit is contained in:
1 parent
24aa15d39a
commit
df4be0cec8
2 files changed
+8
-3
No files matched your search
+8
-3
@@ -1441,15 +1441,20 @@ hb_gpu_paint_encode (hb_gpu_paint_t *paint,
|
||||
void
|
||||
hb_gpu_paint_clear (hb_gpu_paint_t *paint)
|
||||
{
|
||||
paint->ops.resize (0);
|
||||
/* Use reset() not resize(0): if an earlier push_or_fail() set
|
||||
* the vector's error state (common under failing-malloc),
|
||||
* resize(0) short-circuits without clearing length. A
|
||||
* subsequent clear would double-destroy the blob pointers left
|
||||
* in the array, or keep stale ops across encodes. */
|
||||
paint->ops.reset ();
|
||||
paint->num_ops = 0;
|
||||
for (hb_blob_t *b : paint->sub_blobs)
|
||||
hb_blob_destroy (b);
|
||||
paint->sub_blobs.resize (0);
|
||||
paint->sub_blobs.reset ();
|
||||
paint->clip_depth = 0;
|
||||
paint->unsupported = false;
|
||||
paint->cur_transform = {1, 0, 0, 1, 0, 0};
|
||||
paint->transform_stack.resize (0);
|
||||
paint->transform_stack.reset ();
|
||||
paint->ext_min_x = 0x7fffffff;
|
||||
paint->ext_min_y = 0x7fffffff;
|
||||
paint->ext_max_x = -0x7fffffff;
|
||||
|
||||
Reference in new issue
Block a user