]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libtest: call PR_Cleanup() on exit if NSPR is used
authorKamil Dudka <kdudka@redhat.com>
Tue, 14 Jul 2015 15:08:44 +0000 (17:08 +0200)
committerKamil Dudka <kdudka@redhat.com>
Tue, 14 Jul 2015 19:52:33 +0000 (21:52 +0200)
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ň
tests/libtest/Makefile.am
tests/libtest/first.c

index 6caa3764489c121f03d57fbb00973771474b90c2..d255b222b3d766a73199fc149c1f92e2802f03c5 100644 (file)
@@ -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)
index 0ead39d67cd7d1a4804c8348927fcc3585326d5c..d693173f181f05fdf6e9d58c42dfe4b95884d174 100644 (file)
 #  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;
 }