Skip to content

Commit

Permalink
fix fault where op1 is unused in ZEND_INIT_STATIC_METHOD_CALL
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Sep 30, 2016
1 parent 6cfc06d commit 7156777
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,19 @@ int uopz_call_handler(UOPZ_OPCODE_HANDLER_ARGS) { /* {{{ */
case ZEND_INIT_STATIC_METHOD_CALL: {
zend_class_entry *ce;
zval *mock;
zend_string *key;
zend_string *key = NULL;

if (EX(opline)->op1_type == IS_CONST) {
key = zend_string_tolower(Z_STR_P(EX_CONSTANT(EX(opline)->op1)));
} else {
} else if (EX(opline)->op1_type != IS_UNUSED) {
ce = Z_CE_P(EX_VAR(EX(opline)->op1.var));
if (!ce) {
break;
}
key = zend_string_tolower(ce->name);
}

if ((mock = zend_hash_find(&UOPZ(mocks), key))) {
if (key && (mock = zend_hash_find(&UOPZ(mocks), key))) {
zend_class_entry *poser;

if (Z_TYPE_P(mock) == IS_STRING) {
Expand All @@ -203,15 +203,18 @@ int uopz_call_handler(UOPZ_OPCODE_HANDLER_ARGS) { /* {{{ */
}
}

if (EX(opline)->op2_type == IS_CONST) {
if (key && EX(opline)->op2_type == IS_CONST) {
zval *function_name = EX_CONSTANT(EX(opline)->op2);
if (EX(opline)->op1_type == IS_CONST) {
CACHE_PTR(Z_CACHE_SLOT_P(function_name), NULL);
} else {
CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), NULL, NULL);
}
}
zend_string_release(key);

if (key) {
zend_string_release(key);
}
} break;
}

Expand Down

0 comments on commit 7156777

Please sign in to comment.