Commit e45f5f6
committed
Fix GH-22121: double-free in gdImageSetStyle() after overflow early return
gdImageSetStyle freed im->style before checking overflow2(). When the
overflow check tripped and the function early-returned, im->style was
left dangling. The next gdImageSetStyle, gdImageDestroy, or
gdImageSetPixel gdStyled/gdStyledBrushed dispatch then freed or
dereferenced it. Move the overflow check above the free to match
upstream libgd (libgd/libgd src/gd.c::gdImageSetStyle), which has
always had the check first. The original divergence was an oversight
in 77ba248 when the overflow check was ported from libgd 2.0.29.
Fixes GH-221211 parent c56f5ad commit e45f5f6
2 files changed
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2879 | 2879 | | |
2880 | 2880 | | |
2881 | 2881 | | |
2882 | | - | |
2883 | | - | |
2884 | | - | |
2885 | 2882 | | |
2886 | 2883 | | |
2887 | 2884 | | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
2888 | 2888 | | |
2889 | 2889 | | |
2890 | 2890 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments