]> granicus.if.org Git - php/commitdiff
Fix segfault and check for truecolor image in ImageColorAt
authorRasmus Lerdorf <rasmus@php.net>
Thu, 27 Sep 2001 07:36:34 +0000 (07:36 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Thu, 27 Sep 2001 07:36:34 +0000 (07:36 +0000)
@- Fix segfault and check for truecolor image in ImageColorAt (Rasmus)

ext/gd/gd.c

index c40b30db141afdff6156eec35c033c68a6b48f49..7b2c03672e97cb10b9335e86b2356df0caf92d3a 100644 (file)
@@ -1577,10 +1577,17 @@ PHP_FUNCTION(imagecolorat)
        
        ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
 
+#if HAVE_LIBGD20
+       if(im->truecolor) {
+               php_error(E_WARNING, "ImageColorAt does not work on TrueColor images");
+               RETURN_FALSE;
+       }
+#endif
+
        convert_to_long_ex(x);
        convert_to_long_ex(y);
 
-       if (gdImageBoundsSafe(im, Z_LVAL_PP(x), Z_LVAL_PP(y))) {
+       if (im->pixels && gdImageBoundsSafe(im, Z_LVAL_PP(x), Z_LVAL_PP(y))) {
 #if HAVE_LIBGD13
                RETURN_LONG(im->pixels[Z_LVAL_PP(y)][Z_LVAL_PP(x)]);
 #else