[php-src] PR #22125: Fix GH-22121: double-free in gdImageSetStyle() after overflow early return
| From: | iliaal | Date: | Fri, 22 May 2026 12:38:00 +0000 |
| Subject: | [php-src] PR #22125: Fix GH-22121: double-free in gdImageSetStyle() after overflow early return | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36196@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22125
Author: iliaal
gdImageSetStyle (ext/gd/libgd/gd.c:2880) frees im->style before calling
overflow2(). When the overflow check trips and the function returns,
im->style is left dangling and the next gdImageSetStyle,
gdImageDestroy, or gdImageSetPixel
gdStyled/gdStyledBrushed dispatch frees or dereferences 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 divergence was an oversight in
77ba2483d9 when the overflow check was ported from libgd 2.0.29.
Fixes #22121