Skip to content

Commit

Permalink
Fix double free when socket_accept fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Nov 11, 2020
1 parent b4a2a96 commit 800cf5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions ext/sockets/tests/socket_accept_failure.phpt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 800cf5a

Please sign in to comment.