]> granicus.if.org Git - php/commit
Convert Exception::getMessage() result to string
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 25 May 2020 10:10:41 +0000 (12:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 28 May 2020 09:51:35 +0000 (11:51 +0200)
commit55dd3945fb32cf35e0385febc0114a0036d50190
tree960e07d67952b934fb0b4503e8cbbeeae1a26599
parentefbe96166dc32f85e57e2c23e0c1440488a42432
Convert Exception::getMessage() result to string

We specify that the return type of Exception::getMessage() is a
string. However, we don't currently ensure this, because
Exception::$message is a protected member that can be set to any
type. Fix this by performing an explicit type-cast.

This also requires a temporary refcount increment in the __toString()
object handler, because there is no additional owner of the object,
and it may get released prematurely as part of the __toString() call.
Zend/tests/exception_delayed_message.phpt [new file with mode: 0644]
Zend/zend_exceptions.c
Zend/zend_object_handlers.c