diff options
| author | Rasmus Lerdorf <rasmus@php.net> | 2000-05-01 18:56:58 +0000 |
|---|---|---|
| committer | Rasmus Lerdorf <rasmus@php.net> | 2000-05-01 18:56:58 +0000 |
| commit | 83f567abf3e579cb2fbae48494fb55432aa1e029 (patch) | |
| tree | c8266be9a6531b85df70b70eb11807c91581cc93 /ext/gd | |
| parent | 113b87736b5b0107ac256cdfb60dface45889973 (diff) | |
| download | php-git-83f567abf3e579cb2fbae48494fb55432aa1e029.tar.gz | |
Dynamically allocate points for ImagePolygon (Marc Pohl)
@Dynamically allocate points for ImagePolygon (Marc Pohl)
Diffstat (limited to 'ext/gd')
| -rw-r--r-- | ext/gd/gd.c | 11 |
1 files 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; } |
