aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/first.c
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2015-07-14 17:08:44 +0200
committerKamil Dudka <kdudka@redhat.com>2015-07-14 21:52:33 +0200
commitcd20e81e89ecebc5064e1d3e22e62e2802b2711e (patch)
treeef7317b7b68f2f61b63ee35e3483963039f82865 /tests/libtest/first.c
parent79416fb2d6d906210c93e6f5710cea201bdf6b0e (diff)
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ň
Diffstat (limited to 'tests/libtest/first.c')
-rw-r--r--tests/libtest/first.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/libtest/first.c b/tests/libtest/first.c
index 0ead39d67..d693173f1 100644
--- a/tests/libtest/first.c
+++ b/tests/libtest/first.c
@@ -33,6 +33,10 @@
# include <fcntl.h> /* for setmode() */
#endif
+#ifdef USE_NSS
+#include <nspr.h>
+#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;
}