]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
test: Missing tor_free() in metrics unit tests
authorDavid Goulet <dgoulet@torproject.org>
Wed, 28 Oct 2020 12:52:02 +0000 (08:52 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 28 Oct 2020 12:52:02 +0000 (08:52 -0400)
Found by coverity:

  *** CID 1468664:  Resource leaks  (RESOURCE_LEAK)
  /src/test/test_metrics.c: 83 in test_config()
  77       tt_int_op(ret, OP_EQ, false);
  78
  79      done:
  80       SMARTLIST_FOREACH(ports, port_cfg_t *, c, port_cfg_free(c));
  81       smartlist_free(ports);
  82       or_options_free(options);
  >>>     CID 1468664:  Resource leaks  (RESOURCE_LEAK)
  >>>     Variable "err_msg" going out of scope leaks the storage it points to.
  83     }
  84
  85     static char _c_buf[256];
  86     #define CONTAINS(conn, msg) \
  87       do { \
  88         tt_int_op(buf_datalen(conn->outbuf), OP_EQ, (strlen(msg))); \

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/test/test_metrics.c

index 26e84a579812fece2cc9e557aa5fb28f5e777e60..1c645813a4a4433e2615f86497f5f4a3d37af339 100644 (file)
@@ -80,6 +80,7 @@ test_config(void *arg)
   SMARTLIST_FOREACH(ports, port_cfg_t *, c, port_cfg_free(c));
   smartlist_free(ports);
   or_options_free(options);
+  tor_free(err_msg);
 }
 
 static char _c_buf[256];