diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-25 12:10:41 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-28 11:51:35 +0200 |
commit | 55dd3945fb32cf35e0385febc0114a0036d50190 (patch) | |
tree | 960e07d67952b934fb0b4503e8cbbeeae1a26599 /Zend/zend_exceptions.c | |
parent | efbe96166dc32f85e57e2c23e0c1440488a42432 (diff) | |
download | php-git-55dd3945fb32cf35e0385febc0114a0036d50190.tar.gz |
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.
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r-- | Zend/zend_exceptions.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index a039d18668..31738b6a86 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -414,8 +414,7 @@ ZEND_METHOD(Exception, getMessage) ZEND_PARSE_PARAMETERS_NONE(); prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_MESSAGE); - ZVAL_DEREF(prop); - ZVAL_COPY(return_value, prop); + RETURN_STR(zval_get_string(prop)); } /* }}} */ |