diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-26 15:32:18 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-05 14:25:07 +0200 |
commit | a31f46421d7bf6f55dd9ac5876b8e2eacf7e0708 (patch) | |
tree | 24ffd7c5ae5e321c3994048fdd0fd9f68ae7457c /main/streams/userspace.c | |
parent | 528aa7932a839fc6319979c34aa372805d8dc41c (diff) | |
download | php-git-a31f46421d7bf6f55dd9ac5876b8e2eacf7e0708.tar.gz |
Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions
And convert some object to string conversion related recoverable
fatal errors into Error exceptions.
Improve exception safety of internal code performing string
conversions.
Diffstat (limited to 'main/streams/userspace.c')
-rw-r--r-- | main/streams/userspace.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 73b71863a4..bdd9b1b48e 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -669,7 +669,10 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count) } if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { - convert_to_string(&retval); + if (!try_convert_to_string(&retval)) { + return -1; + } + didread = Z_STRLEN(retval); if (didread > count) { php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " - read " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " read, " ZEND_LONG_FMT " max) - excess data will be lost", |