From ad99f9968f47b516fb77d4572a06b14822a3ca1f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 Feb 2023 13:15:30 +0100 Subject: [PATCH] sapi/fpm/status: replace variable-length array with emalloc() According to @cmb69, PHP does not require VLA support (https://github.com/php/php-src/pull/10304#discussion_r1069343092). VLAs are a bad idea for several reasons, so let's get rid of them. This is a continuation of https://github.com/php/php-src/pull/10645 --- sapi/fpm/fpm/fpm_status.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 514d60d176e39..aeecf35efc930 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -61,7 +61,10 @@ int fpm_status_export_to_zval(zval *status) /* copy the scoreboard not to bother other processes */ scoreboard = *scoreboard_p; - struct fpm_scoreboard_proc_s procs[scoreboard.nprocs]; + struct fpm_scoreboard_proc_s *procs = safe_emalloc(scoreboard.nprocs, sizeof(*procs), 0); + if (procs == NULL) { + return FAILURE; + } struct fpm_scoreboard_proc_s *proc_p; for(i=0; i