If it is a huge effort to release memory from the testsuite, it may not be worth it. But if it is a small effort, and it leads to being able to run all the testsuite under valgrind without any warnings, I would support doing it.
Yes, it was some hours of work, but here is a patch that releases all memory and now runs fine with valgrind.
There is just changed file outside testsuite/ and examples/ : buffer.c. nettle_buffer_clear() used to call realloc() with a length of 0 to wipe the allocated memory. But at least here it comes back with a valid pointer to one allocated byte (as valgrind reports). I use free() after the realloc if the returned pointer is not NULL (maybe realloc() should not be called at all !?). Niels, please have a look at it.
I did not remove or add any tests, just changed / added / removed some stuff from testutils.c and of course within the *-test.c(xx).
Niels, please remove the quotes from "$EMULATOR" in run-tests (my run-tests is somehow already in the local repo with some other changes I just can't revert). Than we could use EMULATOR="valgrind -q --error-exitcode=1 --leak-check=full --show- reachable=yes" to do an automated memory check.
A short overview of the changed files: # modified: buffer.c # modified: examples/rsa-encrypt.c # modified: examples/rsa-keygen.c # modified: testsuite/aes-test.c # modified: testsuite/arcfour-test.c # modified: testsuite/arctwo-test.c # modified: testsuite/bignum-test.c # modified: testsuite/blowfish-test.c # modified: testsuite/camellia-test.c # modified: testsuite/cast128-test.c # modified: testsuite/cbc-test.c # modified: testsuite/ctr-test.c # modified: testsuite/cxx-test.cxx # modified: testsuite/des-test.c # modified: testsuite/des3-test.c # modified: testsuite/gcm-test.c # modified: testsuite/hmac-test.c # modified: testsuite/md2-test.c # modified: testsuite/md4-test.c # modified: testsuite/md5-compat-test.c # modified: testsuite/md5-test.c # modified: testsuite/memxor-test.c # modified: testsuite/random-prime-test.c # modified: testsuite/ripemd160-test.c # modified: testsuite/rsa2sexp-test.c # modified: testsuite/salsa20-test.c # modified: testsuite/serpent-test.c # modified: testsuite/sexp-format-test.c # modified: testsuite/sexp-test.c # modified: testsuite/sexp2rsa-test.c # modified: testsuite/sha1-test.c # modified: testsuite/sha224-test.c # modified: testsuite/sha256-test.c # modified: testsuite/sha384-test.c # modified: testsuite/sha512-test.c # modified: testsuite/testutils.c # modified: testsuite/testutils.h # modified: testsuite/twofish-test.c # modified: testsuite/yarrow-test.c # modified: tools/pkcs1-conv.c
Regards, Tim