Skip to content

Commit f956434

Browse files
committed
Merge branch 'PHP-7.4' into master
* PHP-7.4: Catch potential exceptions during to string conversion
2 parents bd6feb7 + 2960301 commit f956434

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

ext/com_dotnet/com_com.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,37 @@ PHP_METHOD(com, __construct)
8181

8282
if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params),
8383
"Server", sizeof("Server")-1))) {
84-
convert_to_string_ex(tmp);
84+
if (!try_convert_to_string(tmp)) {
85+
RETURN_THROWS();
86+
}
8587
server_name = Z_STRVAL_P(tmp);
8688
server_name_len = Z_STRLEN_P(tmp);
8789
ctx = CLSCTX_REMOTE_SERVER;
8890
}
8991

9092
if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params),
9193
"Username", sizeof("Username")-1))) {
92-
convert_to_string_ex(tmp);
94+
if (!try_convert_to_string(tmp)) {
95+
RETURN_THROWS();
96+
}
9397
user_name = Z_STRVAL_P(tmp);
9498
user_name_len = Z_STRLEN_P(tmp);
9599
}
96100

97101
if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params),
98102
"Password", sizeof("Password")-1))) {
99-
convert_to_string_ex(tmp);
103+
if (!try_convert_to_string(tmp)) {
104+
RETURN_THROWS();
105+
}
100106
password = Z_STRVAL_P(tmp);
101107
password_len = Z_STRLEN_P(tmp);
102108
}
103109

104110
if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params),
105111
"Domain", sizeof("Domain")-1))) {
106-
convert_to_string_ex(tmp);
112+
if (!try_convert_to_string(tmp)) {
113+
RETURN_THROWS();
114+
}
107115
domain_name = Z_STRVAL_P(tmp);
108116
domain_name_len = Z_STRLEN_P(tmp);
109117
}
@@ -715,7 +723,9 @@ PHP_FUNCTION(com_event_sink)
715723
if ((tmp = zend_hash_index_find(Z_ARRVAL_P(sink), 1)) != NULL && Z_TYPE_P(tmp) == IS_STRING)
716724
dispname = Z_STRVAL_P(tmp);
717725
} else if (sink != NULL) {
718-
convert_to_string(sink);
726+
if (!try_convert_to_string(sink)) {
727+
RETURN_THROWS();
728+
}
719729
dispname = Z_STRVAL_P(sink);
720730
}
721731

ext/com_dotnet/com_saproxy.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ static zval *saproxy_read_dimension(zend_object *object, zval *offset, int type,
105105
}
106106
ZVAL_COPY_VALUE(&args[i-1], offset);
107107

108-
convert_to_string(&proxy->indices[0]);
108+
if (!try_convert_to_string(&proxy->indices[0])) {
109+
efree(args);
110+
return rv;
111+
}
109112
VariantInit(&v);
110113

111114
res = php_com_do_invoke(proxy->obj, Z_STRVAL(proxy->indices[0]),
@@ -220,7 +223,10 @@ static void saproxy_write_dimension(zend_object *object, zval *offset, zval *val
220223
ZVAL_COPY_VALUE(&args[i-1], offset);
221224
ZVAL_COPY_VALUE(&args[i], value);
222225

223-
convert_to_string(&proxy->indices[0]);
226+
if (!try_convert_to_string(&proxy->indices[0])) {
227+
efree(args);
228+
return;
229+
}
224230
VariantInit(&v);
225231
if (SUCCESS == php_com_do_invoke(proxy->obj, Z_STRVAL(proxy->indices[0]),
226232
Z_STRLEN(proxy->indices[0]), DISPATCH_PROPERTYPUT, &v, proxy->dimensions + 1,

0 commit comments

Comments
 (0)