summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/com_saproxy.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-08-25 15:40:17 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-08-27 10:23:18 +0200
commit296030119cec2c1c543b3397dc84977e592a4747 (patch)
treeeaf1a16936cfa18b6116b0e873a49c462301d6e1 /ext/com_dotnet/com_saproxy.c
parent247105ae1ae2a04608078f7fcfe88dacab9f55a4 (diff)
downloadphp-git-296030119cec2c1c543b3397dc84977e592a4747.tar.gz
Catch potential exceptions during to string conversion
As of PHP 7.4.0, exceptions are allowed to be thrown from inside `__toString()` methods; we have to cater to that, and catch these exceptions early. Closes GH-6042
Diffstat (limited to 'ext/com_dotnet/com_saproxy.c')
-rw-r--r--ext/com_dotnet/com_saproxy.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 8369a4bcdd..eec6e2998e 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -108,7 +108,10 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
}
ZVAL_COPY_VALUE(&args[i-1], offset);
- convert_to_string(&proxy->indices[0]);
+ if (!try_convert_to_string(&proxy->indices[0])) {
+ efree(args);
+ return rv;
+ }
VariantInit(&v);
res = php_com_do_invoke(proxy->obj, Z_STRVAL(proxy->indices[0]),
@@ -223,7 +226,10 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value)
ZVAL_COPY_VALUE(&args[i-1], offset);
ZVAL_COPY_VALUE(&args[i], value);
- convert_to_string(&proxy->indices[0]);
+ if (!try_convert_to_string(&proxy->indices[0])) {
+ efree(args);
+ return;
+ }
VariantInit(&v);
if (SUCCESS == php_com_do_invoke(proxy->obj, Z_STRVAL(proxy->indices[0]),
Z_STRLEN(proxy->indices[0]), DISPATCH_PROPERTYPUT, &v, proxy->dimensions + 1,