diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/mem_dbg.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 982aebbe51..36593ed664 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 |