[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Mon Apr 27 16:29:57 UTC 2015


The branch master has been updated
       via  31b222da1ea6fadd22f5cb134f6ba289f81a2adc (commit)
      from  a4d5269e6d0dba0c276c968448a3576f7604666a (commit)


- Log -----------------------------------------------------------------
commit 31b222da1ea6fadd22f5cb134f6ba289f81a2adc
Author: Rich Salz <rsalz at openssl.org>
Date:   Mon Apr 27 12:29:39 2015 -0400

    CRYPTO_mem_leaks should ignore it's BIO argument.
    
    CRYPTO_mem_leaks takes a BIO* argument.  It's not a leak if that
    argument hasn't been free'd.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/openssl.c   |  3 +--
 crypto/mem_dbg.c | 12 +++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/apps/openssl.c b/apps/openssl.c
index b42d031..786f5d3 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -527,8 +527,7 @@ int main(int argc, char *argv[])
     BIO_free(bio_in);
     BIO_free_all(bio_out);
     apps_shutdown();
-    /*CRYPTO_mem_leaks(bio_err);
-     */
+    CRYPTO_mem_leaks(bio_err);
     BIO_free(bio_err);
     return (ret);
 }
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 982aebb..36593ed 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -623,6 +623,7 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
 typedef struct mem_leak_st {
     BIO *bio;
     int chunks;
+    int seen;
     long bytes;
 } MEM_LEAK;
 
@@ -637,8 +638,11 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
 
 #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
 
-    if (m->addr == (char *)l->bio)
+    /* Is one "leak" the BIO we were given? */
+    if (m->addr == (char *)l->bio) {
+        l->seen = 1;
         return;
+    }
 
     if (options & V_CRYPTO_MDEBUG_TIME) {
         lcl = localtime(&m->time);
@@ -722,8 +726,14 @@ void CRYPTO_mem_leaks(BIO *b)
     ml.bio = b;
     ml.bytes = 0;
     ml.chunks = 0;
+    ml.seen = 0;
     if (mh != NULL)
         lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), MEM_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);
 #ifdef CRYPTO_MDEBUG_ABORT


More information about the openssl-commits mailing list