Skip to content

Commit 961412d

Browse files
authored
main: refactor implementation of set_time_limit() (#19338)
1 parent 345e04b commit 961412d

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

main/main.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,24 +1577,16 @@ PHPAPI char *php_get_current_user(void)
15771577
PHP_FUNCTION(set_time_limit)
15781578
{
15791579
zend_long new_timeout;
1580-
char *new_timeout_str;
1581-
size_t new_timeout_strlen;
1582-
zend_string *key;
15831580

15841581
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_timeout) == FAILURE) {
15851582
RETURN_THROWS();
15861583
}
15871584

1588-
new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout);
1589-
1590-
key = ZSTR_INIT_LITERAL("max_execution_time", 0);
1591-
if (zend_alter_ini_entry_chars_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == SUCCESS) {
1592-
RETVAL_TRUE;
1593-
} else {
1594-
RETVAL_FALSE;
1595-
}
1596-
zend_string_release_ex(key, 0);
1597-
efree(new_timeout_str);
1585+
zend_string *time = zend_long_to_str(new_timeout);
1586+
zend_string *key = ZSTR_INIT_LITERAL("max_execution_time", false);
1587+
RETVAL_BOOL(zend_alter_ini_entry_ex(key, time, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, false) == SUCCESS);
1588+
zend_string_release_ex(key, false);
1589+
zend_string_release_ex(time, false);
15981590
}
15991591
/* }}} */
16001592

0 commit comments

Comments
 (0)