test: fix stack-use-after-scope
In both `test-tcp-open` and `test-udp-open`. PR-URL: https://github.com/libuv/libuv/pull/3137 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
parent
67994c68fe
commit
e24e5cbc2b
@ -237,6 +237,7 @@ TEST_IMPL(tcp_open) {
|
||||
struct sockaddr_in addr;
|
||||
uv_os_sock_t sock;
|
||||
int r;
|
||||
uv_tcp_t client2;
|
||||
|
||||
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
|
||||
|
||||
@ -257,8 +258,6 @@ TEST_IMPL(tcp_open) {
|
||||
|
||||
#ifndef _WIN32
|
||||
{
|
||||
uv_tcp_t client2;
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &client2);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -267,7 +266,9 @@ TEST_IMPL(tcp_open) {
|
||||
|
||||
uv_close((uv_handle_t*) &client2, NULL);
|
||||
}
|
||||
#endif /* !_WIN32 */
|
||||
#else /* _WIN32 */
|
||||
(void)client2;
|
||||
#endif
|
||||
|
||||
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ static void send_cb(uv_udp_send_t* req, int status) {
|
||||
TEST_IMPL(udp_open) {
|
||||
struct sockaddr_in addr;
|
||||
uv_buf_t buf = uv_buf_init("PING", 4);
|
||||
uv_udp_t client;
|
||||
uv_udp_t client, client2;
|
||||
uv_os_sock_t sock;
|
||||
int r;
|
||||
|
||||
@ -169,8 +169,6 @@ TEST_IMPL(udp_open) {
|
||||
|
||||
#ifndef _WIN32
|
||||
{
|
||||
uv_udp_t client2;
|
||||
|
||||
r = uv_udp_init(uv_default_loop(), &client2);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -179,7 +177,9 @@ TEST_IMPL(udp_open) {
|
||||
|
||||
uv_close((uv_handle_t*) &client2, NULL);
|
||||
}
|
||||
#endif /* !_WIN32 */
|
||||
#else /* _WIN32 */
|
||||
(void)client2;
|
||||
#endif
|
||||
|
||||
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user