summaryrefslogtreecommitdiff
path: root/ext/sockets
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-11-11 12:48:44 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-11-11 12:48:44 +0100
commit01de00073f16865e38d7bcf167011ae185fed5a3 (patch)
treea9baca2d33369d65c2ec172c4cd082bd405a1294 /ext/sockets
parentd637f0dd3e8df46190c17b2a836d1f6b79668594 (diff)
parent800cf5a20f09baf243c0b7205f827a46bd4904f0 (diff)
downloadphp-git-01de00073f16865e38d7bcf167011ae185fed5a3.tar.gz
Merge branch 'PHP-8.0'
* PHP-8.0: Fix double free when socket_accept fails
Diffstat (limited to 'ext/sockets')
-rw-r--r--ext/sockets/sockets.c1
-rw-r--r--ext/sockets/tests/socket_accept_failure.phpt12
2 files changed, 12 insertions, 1 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index c50d8d5d71..a9d0e4b885 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -272,7 +272,6 @@ static int php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct
if (IS_INVALID_SOCKET(out_sock)) {
PHP_SOCKET_ERROR(out_sock, "unable to accept incoming connection", errno);
- efree(out_sock);
return 0;
}
diff --git a/ext/sockets/tests/socket_accept_failure.phpt b/ext/sockets/tests/socket_accept_failure.phpt
new file mode 100644
index 0000000000..522987469b
--- /dev/null
+++ b/ext/sockets/tests/socket_accept_failure.phpt
@@ -0,0 +1,12 @@
+--TEST--
+socket_accept() failure
+--FILE--
+<?php
+
+$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+var_dump(socket_accept($socket));
+
+?>
+--EXPECTF--
+Warning: socket_accept(): unable to accept incoming connection [%d]: %s in %s on line %d
+bool(false)