summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2000-05-01 18:56:58 +0000
committerRasmus Lerdorf <rasmus@php.net>2000-05-01 18:56:58 +0000
commit83f567abf3e579cb2fbae48494fb55432aa1e029 (patch)
treec8266be9a6531b85df70b70eb11807c91581cc93 /ext/gd
parent113b87736b5b0107ac256cdfb60dface45889973 (diff)
downloadphp-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.c11
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;
}