Re: cvs: /php3/functions gd.c
| From: | Zeev Suraski | Date: | Mon, 01 May 2000 23:39:45 +0000 |
| Subject: | Re: cvs: /php3/functions gd.c | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-18332@lists.php.net to get a copy of this message | ||
As emalloc() cannot fail (or rather, it'll not return if it fails), there's no need to check for NULL return values anymore.
Zeev
At 20:54 01/05/2000 , Rasmus Lerdorf wrote:
-- Zeev Suraski <zeev@zend.com> http://www.zend.com/rasmus Mon May 1 11:54:33 2000 EDTModified files:/php3/functions gd.cLog: 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;} -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net