From: Nikita Popov Date: Thu, 1 Oct 2020 15:10:56 +0000 (+0200) Subject: Add test instantiating all objects X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62c6d6952ead055b2a08636eacdce6bb74168de1;p=php Add test instantiating all objects Intended to find issues in opaque object destructors. Closes GH-6251. --- diff --git a/Zend/tests/instantiate_all_classes.phpt b/Zend/tests/instantiate_all_classes.phpt new file mode 100644 index 0000000000..b8d82530f3 --- /dev/null +++ b/Zend/tests/instantiate_all_classes.phpt @@ -0,0 +1,15 @@ +--TEST-- +Try to instantiate all classes without arguments +--FILE-- + +===DONE=== +--EXPECT-- +===DONE=== diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 6f1ab3cf42..462b125968 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -199,9 +199,9 @@ zend_object *php_gd_image_object_create(zend_class_entry *class_type) static void php_gd_image_object_free(zend_object *intern) { php_gd_image_object *img_obj_ptr = php_gd_exgdimage_from_zobj_p(intern); - gdImageDestroy(img_obj_ptr->image); - img_obj_ptr->image = NULL; - + if (img_obj_ptr->image) { + gdImageDestroy(img_obj_ptr->image); + } zend_object_std_dtor(intern); } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 161396f494..abaf88f15a 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -233,10 +233,7 @@ static void php_openssl_pkey_free_obj(zend_object *object) { php_openssl_pkey_object *key_object = php_openssl_pkey_from_obj(object); - EVP_PKEY *pkey = key_object->pkey; - assert(pkey != NULL); - EVP_PKEY_free(pkey); - + EVP_PKEY_free(key_object->pkey); zend_object_std_dtor(&key_object->std); }