Skip to content

Commit d84ca46

Browse files
committed
GdImage cannot be cloned
1 parent 7496b54 commit d84ca46

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ext/gd/gd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ PHP_MINIT_FUNCTION(gd)
393393

394394
/* setting up the object handlers for the GdImage class */
395395
memcpy(&gd_ext_image_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
396+
gd_ext_image_object_handlers.clone_obj = NULL;
396397
gd_ext_image_object_handlers.free_obj = gd_ext_image_object_free;
397398
gd_ext_image_object_handlers.offset = XtOffsetOf(gd_ext_image_object, std);
398399

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Checks that GdImage instances cannot be cloned
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('gd')) {
6+
die('skip gd extension is not loaded');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$img_src = imagecreatetruecolor(32, 32);
13+
$img_dst = clone $img_src;
14+
15+
?>
16+
--EXPECTF--
17+
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d
18+
Stack trace:
19+
#0 {main}
20+
thrown in %s on line %d

0 commit comments

Comments
 (0)