]> granicus.if.org Git - php/commitdiff
Better fix for bug #71622 (Strings used in pass-as-reference cannot be used to invoke...
authorDmitry Stogov <dmitry@zend.com>
Thu, 18 Feb 2016 20:14:46 +0000 (23:14 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 18 Feb 2016 20:14:46 +0000 (23:14 +0300)
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index ed7e1808188e4ecf3f0ce9053f1ea82dfb728b83..5984b9d9c786a2d0ef5480ede88a8b3c5fb448a5 100644 (file)
@@ -3052,19 +3052,23 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMPVAR|UNUSE
 
                function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
                if (OP2_TYPE != IS_CONST) {
-                       if (OP2_TYPE & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (OP2_TYPE & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
-                               FREE_OP2();
-                               HANDLE_EXCEPTION();
+                                       zend_throw_error(NULL, "Function name must be a string");
+                                       FREE_OP2();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
index 78cf48fa6c4833e24342f6c26b145aff8f441295..36bcd9452b4ef32292150dd36e1f3a8f2be00bae 100644 (file)
@@ -5646,19 +5646,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
 
                function_name = EX_CONSTANT(opline->op2);
                if (IS_CONST != IS_CONST) {
-                       if (IS_CONST & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (IS_CONST & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
+                                       zend_throw_error(NULL, "Function name must be a string");
 
-                               HANDLE_EXCEPTION();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -7630,19 +7634,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
 
                function_name = NULL;
                if (IS_UNUSED != IS_CONST) {
-                       if (IS_UNUSED & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (IS_UNUSED & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
+                                       zend_throw_error(NULL, "Function name must be a string");
 
-                               HANDLE_EXCEPTION();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -9376,19 +9384,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
 
                function_name = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
                if (IS_CV != IS_CONST) {
-                       if (IS_CV & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (IS_CV & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
+                                       zend_throw_error(NULL, "Function name must be a string");
 
-                               HANDLE_EXCEPTION();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -11187,19 +11199,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
 
                function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
                if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
-                       if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
-                               zval_ptr_dtor_nogc(free_op2);
-                               HANDLE_EXCEPTION();
+                                       zend_throw_error(NULL, "Function name must be a string");
+                                       zval_ptr_dtor_nogc(free_op2);
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -17527,19 +17543,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
 
                function_name = EX_CONSTANT(opline->op2);
                if (IS_CONST != IS_CONST) {
-                       if (IS_CONST & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (IS_CONST & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
+                                       zend_throw_error(NULL, "Function name must be a string");
 
-                               HANDLE_EXCEPTION();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -19158,19 +19178,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
 
                function_name = NULL;
                if (IS_UNUSED != IS_CONST) {
-                       if (IS_UNUSED & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (IS_UNUSED & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
+                                       zend_throw_error(NULL, "Function name must be a string");
 
-                               HANDLE_EXCEPTION();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -20782,19 +20806,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
 
                function_name = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
                if (IS_CV != IS_CONST) {
-                       if (IS_CV & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if (IS_CV & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
+                                       zend_throw_error(NULL, "Function name must be a string");
 
-                               HANDLE_EXCEPTION();
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }
 
@@ -22355,19 +22383,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
 
                function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
                if ((IS_TMP_VAR|IS_VAR) != IS_CONST) {
-                       if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) {
-                               ZVAL_DEREF(function_name);
-                       }
                        if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
-                               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
-                                       GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
-                                       if (UNEXPECTED(EG(exception) != NULL)) {
-                                               HANDLE_EXCEPTION();
+                               do {
+                                       if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
+                                               function_name = Z_REFVAL_P(function_name);
+                                               if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
+                                                       break;
+                                               }
+                                       } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
+                                               GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
+                                               if (UNEXPECTED(EG(exception) != NULL)) {
+                                                       HANDLE_EXCEPTION();
+                                               }
                                        }
-                               }
-                               zend_throw_error(NULL, "Function name must be a string");
-                               zval_ptr_dtor_nogc(free_op2);
-                               HANDLE_EXCEPTION();
+                                       zend_throw_error(NULL, "Function name must be a string");
+                                       zval_ptr_dtor_nogc(free_op2);
+                                       HANDLE_EXCEPTION();
+                               } while (0);
                        }
                }