From 83f567abf3e579cb2fbae48494fb55432aa1e029 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Mon, 1 May 2000 18:56:58 +0000 Subject: [PATCH] Dynamically allocate points for ImagePolygon (Marc Pohl) @Dynamically allocate points for ImagePolygon (Marc Pohl) --- ext/gd/gd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 8e89e165ca..85f5a8b25c 100644 --- a/ext/gd/gd.c +++ b/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; } -- 2.40.0