commit 9fbb5a44b801397be69f5be2c2baff05e93af0f6 Author: Nick Mathewson nickm@torproject.org Date: Sat Apr 26 00:13:27 2014 -0400
Fix memory leak in test_util_asprintf --- src/test/test_util.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/test/test_util.c b/src/test/test_util.c index 6d6b6db..256d849 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2241,18 +2241,21 @@ test_util_asprintf(void *ptr) test_assert(cp); test_streq("simple string 100% safe", cp); test_eq(strlen(cp), r); + tor_free(cp);
/* empty string */ r = tor_asprintf(&cp, "%s", ""); test_assert(cp); test_streq("", cp); test_eq(strlen(cp), r); + tor_free(cp);
/* numbers (%i) */ r = tor_asprintf(&cp, "I like numbers-%2i, %i, etc.", -1, 2); test_assert(cp); test_streq("I like numbers--1, 2, etc.", cp); test_eq(strlen(cp), r); + /* don't free cp; next test uses it. */
/* numbers (%d) */ r = tor_asprintf(&cp2, "First=%d, Second=%d", 101, 202);