Skip to content

Commit 6342fd4

Browse files
committed
Removal of unnecessary tests, removal of image pointer validation
1 parent aa5000a commit 6342fd4

32 files changed

+135
-742
lines changed

ext/gd/gd.c

Lines changed: 87 additions & 273 deletions
Large diffs are not rendered by default.

ext/gd/gd_ctx.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
119119
}
120120
}
121121

122-
if ((im = gd_image_ptr_from_object_zval(imgind)) == NULL) {
123-
return;
124-
125-
}
122+
im = GD_IMAGE_PTR_FROM_ZVAL_P(imgind);
126123

127124
if (image_type != PHP_GDIMG_TYPE_BMP && argc >= 3) {
128125
q = quality; /* or colorindex for foreground of BW images (defaults to black) */

ext/gd/php_gd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
zend_class_entry *gd_image_ce;
2828

29-
static gdImagePtr gd_image_ptr_from_object_zval(zval* zptr);
29+
#define GD_IMAGE_PTR_FROM_ZVAL_P(x) (((gd_ext_image_object*)Z_OBJ_P(x))->image)
30+
3031
static zend_object* gd_ext_image_object_init(zval* val, gdImagePtr image);
3132

3233
typedef struct _gd_ext_image_object {

ext/gd/tests/bug41442.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ var_dump(imagecreatefromstring($str2));
3131

3232
echo "Done\n";
3333
?>
34-
--EXPECTF--
35-
resource(%d) of type (gd)
36-
resource(%d) of type (gd)
34+
--EXPECT--
35+
object(GdImage)#2 (0) {
36+
}
37+
object(GdImage)#2 (0) {
38+
}
3739
Done

ext/gd/tests/bug66356.phpt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ var_dump(imagecrop($img, array("x" => 0x7fffff00, "y" => 0, "width" => 10, "heig
2828
var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => 65535, "height" => 65535)));
2929
?>
3030
--EXPECTF--
31-
resource(%d) of type (gd)
32-
resource(%d) of type (gd)
31+
object(GdImage)#2 (0) {
32+
}
33+
object(GdImage)#2 (0) {
34+
}
3335
Array
3436
(
3537
[x] => a
@@ -39,11 +41,13 @@ Array
3941
)
4042

4143
Warning: imagecrop(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
42-
in %sbug66356.php on line %d
44+
in %s on line %d
4345
bool(false)
44-
resource(%d) of type (gd)
45-
resource(%d) of type (gd)
46+
object(GdImage)#2 (0) {
47+
}
48+
object(GdImage)#2 (0) {
49+
}
4650

4751
Warning: imagecrop(): product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
48-
in %sbug66356.php on line %d
52+
in %s on line %d
4953
bool(false)

ext/gd/tests/bug70976.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ $img = imagerotate(imagecreate(10,10),45,0x7ffffff9);
1010
var_dump($img);
1111
?>
1212
--EXPECT--
13-
resource(5) of type (gd)
13+
object(GdImage)#2 (0) {
14+
}

ext/gd/tests/bug73968.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ if (!extension_loaded('gd')) die('skip gd extension not available');
99
$im = imagecreatefromxbm(__DIR__ . DIRECTORY_SEPARATOR . 'bug73968.xbm');
1010
var_dump($im);
1111
?>
12-
===DONE===
13-
--EXPECTF--
14-
resource(%d) of type (gd)
15-
===DONE===
12+
--EXPECT--
13+
object(GdImage)#1 (0) {
14+
}

ext/gd/tests/bug74435.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ for ($i = 0; $i < $width; $i += 16) {
2121
}
2222
}
2323
?>
24-
===DONE===
25-
--EXPECTF--
26-
resource(%d) of type (gd)
27-
===DONE===
24+
--EXPECT--
25+
object(GdImage)#1 (0) {
26+
}

ext/gd/tests/bug77269.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ memory_limit=2G
1010
--FILE--
1111
<?php
1212
$im = imagecreate(2**28, 1);
13-
if(is_resource($im)) {
14-
imagescale($im, 1, 1, IMG_TRIANGLE);
15-
}
13+
imagescale($im, 1, 1, IMG_TRIANGLE);
14+
1615
?>
1716
===DONE===
1817
--EXPECTF--

ext/gd/tests/bug77391.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstrea
99
<?php
1010
var_dump(imagecreatefrombmp(__DIR__ . '/bug77391.bmp'));
1111
?>
12-
===DONE===
13-
--EXPECTF--
14-
resource(%d) of type (gd)
15-
===DONE===
12+
--EXPECT--
13+
object(GdImage)#1 (0) {
14+
}

0 commit comments

Comments
 (0)