@@ -194,15 +194,22 @@ static int zend_std_call_op_handler(zend_uchar opcode, zval *result, zval *op1,
194
194
zend_class_entry * orig_fake_scope = EG (fake_scope );
195
195
zend_fcall_info fci ;
196
196
zend_fcall_info_cache fcic ;
197
- zval params [2 ] = {* op1 , * op2 };
198
197
199
198
EG (fake_scope ) = NULL ;
200
199
201
- /* op handlers like __add are called with two operands op1, op2 */
200
+ /* __bitwiseNot is a unary operator and only have one argument */
201
+ if (opcode == ZEND_BW_NOT ) {
202
+ fci .param_count = 1 ;
203
+ zval params [1 ] = {* op1 };
204
+ fci .params = params ;
205
+ } else { /* op handlers like __add are called with two operands op1, op2 */
206
+ fci .param_count = 2 ;
207
+ zval params [2 ] = {* op1 , * op2 };
208
+ fci .params = params ;
209
+ }
210
+
202
211
fci .size = sizeof (fci );
203
212
fci .retval = result ;
204
- fci .param_count = 2 ;
205
- fci .params = params ;
206
213
fci .no_separation = 1 ;
207
214
//ZVAL_UNDEF(&fci.function_name); /* Unused */
208
215
@@ -261,6 +268,10 @@ static int zend_std_call_op_handler(zend_uchar opcode, zval *result, zval *op1,
261
268
fcic .function_handler = ce -> __bitwiseXor ;
262
269
ZVAL_STRING (& fci .function_name , "__bitwiseXor" );
263
270
break ;
271
+ case ZEND_BW_NOT :
272
+ fcic .function_handler = ce -> __bitwiseNot ;
273
+ ZVAL_STRING (& fci .function_name , "__bitwiseNot" );
274
+ break ;
264
275
default :
265
276
return FAILURE ;
266
277
break ;
@@ -286,17 +297,25 @@ static int zend_std_call_op_handler(zend_uchar opcode, zval *result, zval *op1,
286
297
287
298
288
299
/* Check if the given types are supported by the given handler signature */
289
-
290
- zval * arr [2 ] = {op1 , op2 };
291
- if (!zend_check_arg_types (fcic .function_handler , 2 , arr ))
292
- {
293
- if (zobj == Z_OBJ_P (op1 ) && Z_TYPE_P (op2 ) == IS_OBJECT ) {
294
- goto retry ;
295
- } else {
296
- zend_type_error ("The operand handlers do not support the given operand types!" );
300
+ if (opcode != ZEND_BW_NOT ) {
301
+ zval * arr [2 ] = {op1 , op2 };
302
+ if (!zend_check_arg_types (fcic .function_handler , 2 , arr ))
303
+ {
304
+ if (zobj == Z_OBJ_P (op1 ) && Z_TYPE_P (op2 ) == IS_OBJECT ) {
305
+ goto retry ;
306
+ } else {
307
+ zend_type_error ("The operand handlers do not support the given operand types!" );
308
+ }
309
+ }
310
+ } else {
311
+ zval * arr [1 ] = {op1 };
312
+ if (!zend_check_arg_types (fcic .function_handler , 1 , arr ))
313
+ {
314
+ zend_type_error ("The operand handlers do not support the given operand types!" );
297
315
}
298
316
}
299
317
318
+
300
319
fcic .called_scope = ce ;
301
320
fcic .object = zobj ;
302
321
fcic .function_handler -> type = ZEND_USER_FUNCTION ;
@@ -305,7 +324,7 @@ static int zend_std_call_op_handler(zend_uchar opcode, zval *result, zval *op1,
305
324
306
325
/** The operand handler can either return PHP_OPERAND_NOT_SUPPORTED */
307
326
if (Z_TYPE_P (result ) == IS_NULL ) {
308
- if (zobj == Z_OBJ_P (op1 ) && Z_TYPE_P (op2 ) == IS_OBJECT ) {
327
+ if (zobj == Z_OBJ_P (op1 ) && op2 != NULL && Z_TYPE_P (op2 ) == IS_OBJECT ) {
309
328
goto retry ;
310
329
} else {
311
330
zend_type_error ("The operand handlers do not support the given operand types!" );
0 commit comments