Skip to content

Commit e9fe9b0

Browse files
committed
ext/sockets: drop convert_to_array for multicast leave group settings.
1 parent e4ad271 commit e9fe9b0

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

ext/sockets/multicast.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,16 @@ mcast_req_fun: ;
159159
php_sockaddr_storage group = {0};
160160
socklen_t glen;
161161

162-
convert_to_array(arg4);
163-
opt_ht = Z_ARRVAL_P(arg4);
162+
if (Z_TYPE_P(arg4) != IS_ARRAY) {
163+
if (UNEXPECTED(Z_TYPE_P(arg4) != IS_OBJECT)) {
164+
zend_type_error("must be of type array when argument #3 ($option) is MCAST_LEAVE_GROUP, %s given", zend_zval_value_name(arg4));
165+
return FAILURE;
166+
} else {
167+
opt_ht = Z_OBJPROP_P(arg4);
168+
}
169+
} else {
170+
opt_ht = Z_ARRVAL_P(arg4);
171+
}
164172

165173
if (php_get_address_from_array(opt_ht, "group", php_sock, &group,
166174
&glen) == FAILURE) {
@@ -194,9 +202,16 @@ mcast_req_fun: ;
194202
source = {0};
195203
socklen_t glen,
196204
slen;
197-
198-
convert_to_array(arg4);
199-
opt_ht = Z_ARRVAL_P(arg4);
205+
if (Z_TYPE_P(arg4) != IS_ARRAY) {
206+
if (UNEXPECTED(Z_TYPE_P(arg4) != IS_OBJECT)) {
207+
zend_type_error("must be of type array when argument #3 ($option) is MCAST_LEAVE_SOURCE_GROUP, %s given", zend_zval_value_name(arg4));
208+
return FAILURE;
209+
} else {
210+
opt_ht = Z_OBJPROP_P(arg4);
211+
}
212+
} else {
213+
opt_ht = Z_ARRVAL_P(arg4);
214+
}
200215

201216
if (php_get_address_from_array(opt_ht, "group", php_sock, &group,
202217
&glen) == FAILURE) {

0 commit comments

Comments
 (0)