mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
* Prevent direct instantiation of com_safearray_proxy
The `com_safearray_proxy` class is meant for internal usage, but so far
it was possible to instantiate it from userland, although that made no
sense. However, a while ago there was a relevant change[1], namely
that its `default_object_handlers` are now assigned when the class is
registered, while previously they only have been assigned when an
instance had been created internally. So now when freeing a manually
created object, `free_obj()` is called, although the object never has
been properly initialized (causing segfaults).
We fix this by introducing a `create_object()` handler which properly
initializes the object with dummy values. Since a manually created
`com_safearray_proxy` still does not make sense, we disallow its
instantiation.
[1] <94ee4f9834>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
15 lines
296 B
PHP
15 lines
296 B
PHP
--TEST--
|
|
Manual instantiation of com_safearray_proxy is not allowed
|
|
--EXTENSIONS--
|
|
com_dotnet
|
|
--FILE--
|
|
<?php
|
|
try {
|
|
new com_safearray_proxy();
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), PHP_EOL;
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Cannot directly construct com_safeproxy_array; it is for internal usage only
|