]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Coverity: fix memory leak on error in test function.
authorNick Mathewson <nickm@torproject.org>
Fri, 28 Jun 2019 16:27:51 +0000 (12:27 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 28 Jun 2019 16:36:53 +0000 (12:36 -0400)
The function make_intro_from_plaintext() in test_introduce.c would
leak memory if we ever hit a failure from our underlying crypto
functions.  This kind of failure should be impossible, but it's best
to be safe here.

Bugfix on 0.2.4.1-alpha.

src/test/test_introduce.c

index 4a6d90d97e2c73ade755483a2efb90581e1b8b83..104e973b1f49251648b2671c0762135e4841e144 100644 (file)
@@ -383,8 +383,10 @@ make_intro_from_plaintext(
 
   /* Output the cell */
   *cell_out = cell;
+  cell = NULL;
 
  done:
+  tor_free(cell);
   return cell_len;
 }
 
@@ -535,4 +537,3 @@ struct testcase_t introduce_tests[] = {
   INTRODUCE_LEGACY(late_parse_v3),
   END_OF_TESTCASES
 };
-