diff --git a/Zend/tests/temporary_cleaning_014.phpt b/Zend/tests/temporary_cleaning_014.phpt index 732ac1303072e..99260af7b7800 100644 --- a/Zend/tests/temporary_cleaning_014.phpt +++ b/Zend/tests/temporary_cleaning_014.phpt @@ -6,7 +6,7 @@ gmp diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index aaab3c9fd3ad9..145e2fd12e5ba 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -270,6 +270,12 @@ static inline void gmp_create(zval *target, mpz_ptr *gmpnum_target) /* {{{ */ } /* }}} */ +static zend_function *gmp_get_constructor(zend_object *object) +{ + zend_throw_error(NULL, "Cannot directly construct GMP, use gmp_init() instead"); + return NULL; +} + static int gmp_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { mpz_ptr gmpnum; @@ -534,6 +540,7 @@ ZEND_MINIT_FUNCTION(gmp) memcpy(&gmp_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); gmp_object_handlers.offset = XtOffsetOf(gmp_object, std); gmp_object_handlers.free_obj = gmp_free_object_storage; + gmp_object_handlers.get_constructor = gmp_get_constructor; gmp_object_handlers.cast_object = gmp_cast_object; gmp_object_handlers.get_debug_info = gmp_get_debug_info; gmp_object_handlers.clone_obj = gmp_clone_obj; diff --git a/ext/gmp/tests/bug-gh10155.phpt b/ext/gmp/tests/bug-gh10155.phpt new file mode 100644 index 0000000000000..72de74e8bbf3b --- /dev/null +++ b/ext/gmp/tests/bug-gh10155.phpt @@ -0,0 +1,14 @@ +--TEST-- +GMP constructor should not be called directly +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), "\n"; +} +?> +--EXPECT-- +Cannot directly construct GMP, use gmp_init() instead