Skip to content

TMP_VAR is not only used once #183

@laruence

Description

@laruence

This is the reason for issue #176 , thanks for the reporter provided a vps for me to debugging.

the new repleace_tmp_by_const assume TMP_VAR is used only once

static void replace_tmp_by_const(zend_op_array *op_array,
                                 zend_op       *opline,
                                 zend_uint      var,
                                 zval          *val
                                 TSRMLS_DC)
{
    zend_op *end = op_array->opcodes + op_array->last;

    while (opline < end) {
        if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR &&
            ZEND_OP1(opline).var == var) {

            update_op1_const(op_array, opline, val TSRMLS_CC);
            /* TMP_VAR my be used only once */
            break;
        }

unfortunately it's not, for a example:

<?php
switch(PHP_OS)
{
        case "Linux":
        break;
        case "Linux":
        break;
        case "Darwin":
        break;
}

the FETCH_CONSTENT result will be used multiply times. include a implicit ZEND_FREE

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions