]> granicus.if.org Git - php/commitdiff
Don't leak peername if accept fails
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 14 Apr 2020 14:05:57 +0000 (16:05 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 14 Apr 2020 14:07:39 +0000 (16:07 +0200)
Even if the accept fails, the peername may be populated.

ext/standard/streamsfuncs.c

index 6fbfb0bcdc50436e05699ef00e32ceaf848ae893..493f3d08645f0b2a626a410f949aff007ecbdadc 100644 (file)
@@ -295,6 +295,9 @@ PHP_FUNCTION(stream_socket_accept)
                }
                php_stream_to_zval(clistream, return_value);
        } else {
+               if (peername) {
+                       zend_string_release(peername);
+               }
                php_error_docref(NULL, E_WARNING, "accept failed: %s", errstr ? ZSTR_VAL(errstr) : "Unknown error");
                RETVAL_FALSE;
        }