cvs: /php3/functions gd.c
| From: | Rasmus Lerdorf | Date: | Mon, 01 May 2000 18:54:33 +0000 |
| Subject: | cvs: /php3/functions gd.c | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-18327@lists.php.net to get a copy of this message | ||
rasmus Mon May 1 11:54:33 2000 EDT
Modified files:
/php3/functions gd.c
Log:
Dynamically allocate points for ImagePolygon() (Marc Pohl)
Index: php3/functions/gd.c
diff -u php3/functions/gd.c:1.150 php3/functions/gd.c:1.151
--- php3/functions/gd.c:1.150 Fri Apr 21 10:27:19 2000
+++ php3/functions/gd.c Mon May 1 11:54:32 2000
@@ -29,7 +29,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.150 2000/04/21 17:27:19 sterling Exp $ */
+/* $Id: gd.c,v 1.151 2000/05/01 18:54:32 rasmus Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -158,8 +158,6 @@
#endif
-#define PolyMaxPoints 256
-
static void php3i_destructor_gdImageDestroy(gdImagePtr img) {
(void)gdImageDestroy(img);
}
@@ -1672,7 +1670,7 @@
static void _php3_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) {
pval *IM, *POINTS, *NPOINTS, *COL, *var;
gdImagePtr im;
- gdPoint points[PolyMaxPoints];
+ gdPointPtr points;
int npoints, col, nelem, i;
int ind_type;
GD_TLS_VARS;
@@ -1724,8 +1722,9 @@
RETURN_FALSE;
}
- if (npoints > PolyMaxPoints) {
- php3_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;
}
@@ -1746,6 +1745,8 @@
else {
gdImagePolygon(im, points, npoints, col);
}
+
+ efree(points);
RETURN_TRUE;
}