mirror of
https://github.com/php/php-src.git
synced 2026-04-11 01:53:36 +02:00
Dynamically allocate points for ImagePolygon (Marc Pohl)
@Dynamically allocate points for ImagePolygon (Marc Pohl)
This commit is contained in:
11
ext/gd/gd.c
11
ext/gd/gd.c
@@ -176,8 +176,6 @@ DLEXPORT zend_module_entry *get_module(void) { return &gd_module_entry; }
|
||||
#endif
|
||||
|
||||
|
||||
#define PolyMaxPoints 256
|
||||
|
||||
static void php_free_gd_font(gdFontPtr fp)
|
||||
{
|
||||
if (fp->data) {
|
||||
@@ -1418,7 +1416,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) {
|
||||
zval **IM, **POINTS, **NPOINTS, **COL;
|
||||
pval **var = NULL;
|
||||
gdImagePtr im;
|
||||
gdPoint points[PolyMaxPoints];
|
||||
gdPointPtr points;
|
||||
int npoints, col, nelem, i;
|
||||
GDLS_FETCH();
|
||||
|
||||
@@ -1464,8 +1462,9 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (npoints > PolyMaxPoints) {
|
||||
php_error(E_WARNING, "maximum %d points", PolyMaxPoints);
|
||||
points = (gdPointPtr) emalloc(npoints * sizeof(gdPoint));
|
||||
if (points == NULL) {
|
||||
php_error(E_WARNING, "ImagePolygon: Memory allocation fault");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -1489,6 +1488,8 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) {
|
||||
gdImagePolygon(im, points, npoints, col);
|
||||
}
|
||||
|
||||
efree(points);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user