Fix a subtle memory leak in test_exorport.c

This is a _subtle_ bug introduced by d1494d14, which resolved
connections that was allocated in the extorport/handshake test.  So
how did the connection get freed?  Our test was set up so that every
extorport connection would get the same ext_or_id.  Two connections
couldn't have the same ext_or_id, and if they did, one would get
freed.  This meant that the _next_ connection to be constructed in
the test would cause the previous connection to become closeable,
even if it hadn't been closeable before.

But when we applied d149d14, we stopped making it so our code
enforced this uniqueness, and thereby make it so we _weren't_
freeing this connection in the tests.

Closes #40260; bug not in any released version of Tor.
This commit is contained in:
Nick Mathewson 2021-01-26 16:58:27 -05:00
parent 930a17f347
commit 37ea6cd9eb

View File

@ -473,7 +473,7 @@ test_ext_or_handshake(void *arg)
tt_int_op(handshake_start_called,OP_EQ,1);
tt_int_op(TO_CONN(conn)->type, OP_EQ, CONN_TYPE_OR);
tt_int_op(TO_CONN(conn)->state, OP_EQ, 0);
close_closeable_connections();
connection_free_(TO_CONN(conn));
conn = NULL;
/* Okay, this time let's succeed the handshake but fail the USERADDR