Skip to content

Commit

Permalink
Remove unnecessary ast eval bailout
Browse files Browse the repository at this point in the history
We can just reset the filename_override to NULL in php_request_shutdown.

Closes GH-9805
  • Loading branch information
iluuu1994 committed Oct 27, 2022
1 parent 9bf61d6 commit 1d6b32f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
11 changes: 1 addition & 10 deletions Zend/zend_ast.c
Expand Up @@ -801,8 +801,6 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_ex(zval *result, zend_ast *as
{
zend_string *class_name = zend_ast_get_str(ast->child[0]);
zend_string *const_name = zend_ast_get_str(ast->child[1]);
zval *zv;
bool bailout = 0;

zend_string *previous_filename;
zend_long previous_lineno;
Expand All @@ -812,18 +810,11 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_ex(zval *result, zend_ast *as
EG(filename_override) = scope->info.user.filename;
EG(lineno_override) = zend_ast_get_lineno(ast);
}
zend_try {
zv = zend_get_class_constant_ex(class_name, const_name, scope, ast->attr);
} zend_catch {
bailout = 1;
} zend_end_try();
zval *zv = zend_get_class_constant_ex(class_name, const_name, scope, ast->attr);
if (scope) {
EG(filename_override) = previous_filename;
EG(lineno_override) = previous_lineno;
}
if (bailout) {
zend_bailout();
}

if (UNEXPECTED(zv == NULL)) {
ZVAL_UNDEF(result);
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_execute_API.c
Expand Up @@ -471,8 +471,6 @@ void shutdown_executor(void) /* {{{ */
if (EG(ht_iterators) != EG(ht_iterators_slots)) {
efree(EG(ht_iterators));
}

ZEND_ASSERT(EG(filename_override) == NULL);
}

#if ZEND_DEBUG
Expand Down
3 changes: 3 additions & 0 deletions main/main.c
Expand Up @@ -1588,6 +1588,9 @@ static void php_free_request_globals(void)
efree(PG(php_sys_temp_dir));
PG(php_sys_temp_dir) = NULL;
}

EG(filename_override) = NULL;
EG(lineno_override) = -1;
}
/* }}} */

Expand Down

0 comments on commit 1d6b32f

Please sign in to comment.