[tor-commits] [tor/master] Fix memory leak in test_onion_queues

nickm at torproject.org nickm at torproject.org
Thu May 1 16:31:43 UTC 2014


commit 1cf02605d4819f200ac70df6ea6c75cfd1ef14e5
Author: Nick Mathewson <nickm at torproject.org>
Date:   Sat Apr 26 00:11:17 2014 -0400

    Fix memory leak in test_onion_queues
---
 src/test/test.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/test/test.c b/src/test/test.c
index f1486e9..9bceab5 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -418,9 +418,10 @@ test_onion_queues(void)
   or_circuit_t *circ1 = or_circuit_new(0, NULL);
   or_circuit_t *circ2 = or_circuit_new(0, NULL);
 
-  create_cell_t *onionskin = NULL;
+  create_cell_t *onionskin = NULL, *create2_ptr;
   create_cell_t *create1 = tor_malloc_zero(sizeof(create_cell_t));
   create_cell_t *create2 = tor_malloc_zero(sizeof(create_cell_t));
+  create2_ptr = create2; /* remember, but do not free */
 
   create_cell_init(create1, CELL_CREATE, ONION_HANDSHAKE_TYPE_TAP,
                    TAP_ONIONSKIN_CHALLENGE_LEN, buf1);
@@ -440,6 +441,7 @@ test_onion_queues(void)
   test_eq_ptr(circ2, onion_next_task(&onionskin));
   test_eq(1, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
   test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
+  tt_ptr_op(onionskin, ==, create2_ptr);
 
   clear_pending_onions();
   test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
@@ -450,6 +452,7 @@ test_onion_queues(void)
   circuit_free(TO_CIRCUIT(circ2));
   tor_free(create1);
   tor_free(create2);
+  tor_free(onionskin);
 }
 
 static void





More information about the tor-commits mailing list