]> granicus.if.org Git - php/commitdiff
- MFB: #39286, misleading error message when invalid dimensions are given
authorPierre Joye <pajoye@php.net>
Sun, 10 Dec 2006 03:03:48 +0000 (03:03 +0000)
committerPierre Joye <pajoye@php.net>
Sun, 10 Dec 2006 03:03:48 +0000 (03:03 +0000)
ext/gd/gd.c
ext/gd/tests/bug38212.phpt
ext/gd/tests/bug39286.phpt [new file with mode: 0644]

index ac73d3e89ab23f82fc321b0a9cf57db737c4884f..efdc399cfef616b9afdba4e89fe975a222c3e451 100644 (file)
@@ -2125,6 +2125,10 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zllll", &ppfilename, &srcx, &srcy, &width, &height) == FAILURE) {
                        return;
                }
+               if (width < 1 || height < 1) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Zero width or height not allowed");
+                       RETURN_FALSE;
+               }
        } else {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &ppfilename) == FAILURE) {
                        return;
index 0094712a553908b2f23fa599b7faf3ac95dfe57f..04c89fece4f64be2abc79eaec7d9f4c091e4568f 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-imagecopy doen't copy alpha, palette to truecolor
+Bzg #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
 --SKIPIF--
 <?php
         if (!function_exists('imagecopy')) die("skip gd extension not available\n");
@@ -14,4 +14,5 @@ $im = imagecreatefromgd2part($file, 0,0, -25,10);
 unlink($file);
 ?>
 --EXPECTF--
-Warning: imagecreatefromgd2part(): '%sbug38212.gd2' is not a valid GD2 file in %sbug38212.php on line %d
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
diff --git a/ext/gd/tests/bug39286.phpt b/ext/gd/tests/bug39286.phpt
new file mode 100644 (file)
index 0000000..3f2a178
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #39508 (imagefill crashes with small images 3 pixels or less)
+--SKIPIF--
+<?php 
+       if (!extension_loaded('gd')) die("skip gd extension not available\n"); 
+       if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100);
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d