sparcv9cap.c: add Fujitsu SPARC64 X AES capability detection.
[openssl.git] / crypto / mem_dbg.c
index e69869d0e95e6a9fc40e7dd5fe20a09cc3b35a18..2b8cf73028deac21ff1ec542dd44fb293179620b 100644 (file)
 #include "internal/threads.h"
 #include <openssl/crypto.h>
 #include <openssl/buffer.h>
-#include <openssl/bio.h>
+#include "internal/bio.h"
 #include <openssl/lhash.h>
 
 #ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
@@ -536,7 +536,6 @@ void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num,
 typedef struct mem_leak_st {
     BIO *bio;
     int chunks;
-    int seen;
     long bytes;
 } MEM_LEAK;
 
@@ -560,12 +559,6 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
 
 #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
 
-    /* Is one "leak" the BIO we were given? */
-    if (m->addr == (char *)l->bio) {
-        l->seen = 1;
-        return;
-    }
-
     lcl = localtime(&m->time);
     BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
                  lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
@@ -643,6 +636,12 @@ int CRYPTO_mem_leaks(BIO *b)
 {
     MEM_LEAK ml;
 
+    /*
+     * OPENSSL_cleanup() will free the ex_data locks so we can't have any
+     * ex_data hanging around
+     */
+    bio_free_ex_data(b);
+
     /* Ensure all resources are released */
     OPENSSL_cleanup();
 
@@ -653,14 +652,9 @@ int CRYPTO_mem_leaks(BIO *b)
     ml.bio = b;
     ml.bytes = 0;
     ml.chunks = 0;
-    ml.seen = 0;
     if (mh != NULL)
         lh_MEM_doall_MEM_LEAK(mh, print_leak, &ml);
-    /* Don't count the BIO that was passed in as a "leak" */
-    if (ml.seen && ml.chunks >= 1 && ml.bytes >= (int)sizeof (*b)) {
-        ml.chunks--;
-        ml.bytes -= (int)sizeof (*b);
-    }
+
     if (ml.chunks != 0) {
         BIO_printf(b, "%ld bytes leaked in %d chunks\n", ml.bytes, ml.chunks);
     } else {