From: Kamil Dudka Date: Tue, 14 Jul 2015 15:08:44 +0000 (+0200) Subject: libtest: call PR_Cleanup() on exit if NSPR is used X-Git-Tag: curl-7_44_0~105 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd20e81e89ecebc5064e1d3e22e62e2802b2711e;p=thirdparty%2Fcurl.git libtest: call PR_Cleanup() on exit if NSPR is used This prevents valgrind from reporting possibly lost memory that NSPR uses for file descriptor cache and other globally allocated internal data structures. Reported-by: Štefan Kremeň --- diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 6caa376448..d255b222b3 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -62,8 +62,8 @@ if USE_EXPLICIT_LIB_DEPS SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@ TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@ else -SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@ -TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@ @NSS_LIBS@ +TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ @NSS_LIBS@ endif # Dependencies (may need to be overriden) diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 0ead39d67c..d693173f18 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -33,6 +33,10 @@ # include /* for setmode() */ #endif +#ifdef USE_NSS +#include +#endif + #ifdef CURLDEBUG # define MEMDEBUG_NODEFINES # include "memdebug.h" @@ -128,6 +132,7 @@ char *hexdump(unsigned char *buffer, size_t len) int main(int argc, char **argv) { char *URL; + int result; #ifdef O_BINARY # ifdef __HIGHC__ @@ -166,5 +171,13 @@ int main(int argc, char **argv) fprintf(stderr, "URL: %s\n", URL); - return test(URL); + result = test(URL); + +#ifdef USE_NSS + if(PR_Initialized()) + /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */ + PR_Cleanup(); +#endif + + return result; }