mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
[vector] Fix clear() when vector is in error state
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>
This commit is contained in:
1 parent
2cde8de822
commit
d134f88824
2 files changed
+2
-1
No files matched your search
+2
-1
@@ -577,7 +577,8 @@ struct hb_vector_t
|
||||
HB_ALWAYS_INLINE_VECTOR_ALLOCS
|
||||
void clear ()
|
||||
{
|
||||
resize (0);
|
||||
if (!resize (0))
|
||||
length = 0; /* If resize fails (e.g. vector in error state), still clear length. */
|
||||
}
|
||||
|
||||
template <typename allocator_t>
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user