Skip to content

Commit 23c2c7c

Browse files
committed
Don’t alloc if there are 0 params
1 parent 1f178f5 commit 23c2c7c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ext/standard/basic_functions.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,11 +1794,16 @@ PHP_FUNCTION(register_shutdown_function)
17941794
Z_PARAM_VARIADIC('+', params, entry.fci.param_count);
17951795
ZEND_PARSE_PARAMETERS_END();
17961796

1797-
entry.fci.params = emalloc(sizeof(zval) * entry.fci.param_count);
1798-
17991797
Z_TRY_ADDREF(entry.fci.function_name);
1800-
for (size_t i = 0; i < entry.fci.param_count; i++) {
1801-
ZVAL_COPY(&entry.fci.params[i], &params[i]);
1798+
1799+
if (entry.fci.param_count) {
1800+
entry.fci.params = emalloc(sizeof(zval) * entry.fci.param_count);
1801+
1802+
for (size_t i = 0; i < entry.fci.param_count; i++) {
1803+
ZVAL_COPY(&entry.fci.params[i], &params[i]);
1804+
}
1805+
} else {
1806+
entry.fci.params = NULL;
18021807
}
18031808

18041809
ZEND_ASSERT(append_user_shutdown_function(&entry));

0 commit comments

Comments
 (0)