Mercurial > hg > octave-lyh > gnulib-hg
changeset 15792:6a126f52efee
base64-tests: avoid memory leak
* tests/test-base64.c (main): Plug memory leak.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Gijs van Tulder <gvtulder@gmail.com> |
---|---|
date | Mon, 26 Sep 2011 19:58:01 +0200 |
parents | d5610338e6f3 |
children | 4e6468fa3ee8 |
files | ChangeLog tests/test-base64.c |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-09-26 Gijs van Tulder <gvtulder@gmail.com> + base64-tests: avoid memory leak + * tests/test-base64.c (main): Plug memory leak. + base32: new module * modules/base32: New module. * lib/base32.c: New file.
--- a/tests/test-base64.c +++ b/tests/test-base64.c @@ -149,6 +149,7 @@ ASSERT (ok); ASSERT (len == 7); ASSERT (memcmp (out, "abcdefg", len) == 0); + free (p); { struct base64_decode_context ctx; @@ -160,6 +161,7 @@ ASSERT (ok); ASSERT (len == strlen (in)); ASSERT (memcmp (p, in, len) == 0); + free (p); } { @@ -170,24 +172,30 @@ ASSERT (ok); ASSERT (len == 9); ASSERT (memcmp (p, "abcdefghi", len) == 0); + free (p); base64_decode_ctx_init (&ctx); ok = base64_decode_alloc_ctx (&ctx, "YW\n", 3, &p, &len); ASSERT (ok); ASSERT (len == 0); + free (p); ok = base64_decode_alloc_ctx (&ctx, "JjZGVmZ2", 8, &p, &len); ASSERT (ok); ASSERT (len == 6); ASSERT (memcmp (p, "abcdef", len) == 0); + free (p); ok = base64_decode_alloc_ctx (&ctx, "hp", 2, &p, &len); ASSERT (ok); ASSERT (len == 3); ASSERT (memcmp (p, "ghi", len) == 0); + free (p); + ok = base64_decode_alloc_ctx (&ctx, "", 0, &p, &len); ASSERT (ok); + free (p); } { @@ -199,6 +207,7 @@ ok = base64_decode_alloc_ctx (&ctx, newlineb64, strlen (newlineb64), &p, &len); ASSERT (ok); ASSERT (len == 0); + free (p); } ok = base64_decode_alloc_ctx (NULL, " ! ", 3, &p, &len);