Commit f082c89
fix: prevent heap-buffer-overflow in ve_fontcache_load on truncated buffers
stbtt_InitFont reads num_tables at data+4 (2 bytes). Passing a 4-byte
buffer caused a 1-byte heap-buffer-overflow read (confirmed by ASan),
which corrupted heap metadata and manifested as a process crash at exit
on clang-cl and an apparent startup crash on MSVC.
Two fixes:
1. Add data_size < 6 guard in ve_fontcache_load before calling stbtt_InitFont,
preventing the out-of-bounds read on any buffer too small for basic header
parsing.
2. Update the lifecycle test to use a 16-byte zero buffer instead of 4 bytes,
so the test still exercises the "invalid data consumes slot" path safely.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent 19aee58 commit f082c89
2 files changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
724 | | - | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
725 | 728 | | |
726 | 729 | | |
727 | 730 | | |
| |||
0 commit comments