Blob Blame History Raw
From 58c6a08e00d4a8c99123cfb36f3a399a9b352d24 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Tue, 10 Jun 2014 10:28:34 +0200
Subject: [PATCH] Fixed bug #67406 built-in web-server segfaults on startup

Reproduce on aarch64.

From select man page:
  "select() may update the timeout argument to indicate how much time was left."
So "const" is not ok.
---
 sapi/cli/php_cli_server.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index e838d30..3fd24ea 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -768,11 +768,11 @@ static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode
 #endif
 } /* }}} */
 
-static int php_cli_server_poller_poll(php_cli_server_poller *poller, const struct timeval *tv) /* {{{ */
+static int php_cli_server_poller_poll(php_cli_server_poller *poller, struct timeval *tv) /* {{{ */
 {
 	memmove(&poller->active.rfds, &poller->rfds, sizeof(poller->rfds));
 	memmove(&poller->active.wfds, &poller->wfds, sizeof(poller->wfds));
-	return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, (struct timeval *)tv);
+	return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, tv);
 } /* }}} */
 
 static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, int fd, int events)) /* {{{ */
@@ -2349,7 +2349,7 @@ static int php_cli_server_do_event_loop(php_cli_server *server TSRMLS_DC) /* {{{
 {
 	int retval = SUCCESS;
 	while (server->is_running) {
-		static const struct timeval tv = { 1, 0 };
+		struct timeval tv = { 1, 0 };
 		int n = php_cli_server_poller_poll(&server->poller, &tv);
 		if (n > 0) {
 			php_cli_server_do_event_for_each_fd(server,
-- 
1.9.2