提交 31b222da 编写于 作者: R Rich Salz

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: NRichard Levitte <levitte@openssl.org>
上级 a4d5269e
...@@ -527,8 +527,7 @@ int main(int argc, char *argv[]) ...@@ -527,8 +527,7 @@ int main(int argc, char *argv[])
BIO_free(bio_in); BIO_free(bio_in);
BIO_free_all(bio_out); BIO_free_all(bio_out);
apps_shutdown(); apps_shutdown();
/*CRYPTO_mem_leaks(bio_err); CRYPTO_mem_leaks(bio_err);
*/
BIO_free(bio_err); BIO_free(bio_err);
return (ret); return (ret);
} }
......
...@@ -623,6 +623,7 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, ...@@ -623,6 +623,7 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
typedef struct mem_leak_st { typedef struct mem_leak_st {
BIO *bio; BIO *bio;
int chunks; int chunks;
int seen;
long bytes; long bytes;
} MEM_LEAK; } MEM_LEAK;
...@@ -637,8 +638,11 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l) ...@@ -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)) #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; return;
}
if (options & V_CRYPTO_MDEBUG_TIME) { if (options & V_CRYPTO_MDEBUG_TIME) {
lcl = localtime(&m->time); lcl = localtime(&m->time);
...@@ -722,8 +726,14 @@ void CRYPTO_mem_leaks(BIO *b) ...@@ -722,8 +726,14 @@ void CRYPTO_mem_leaks(BIO *b)
ml.bio = b; ml.bio = b;
ml.bytes = 0; ml.bytes = 0;
ml.chunks = 0; ml.chunks = 0;
ml.seen = 0;
if (mh != NULL) if (mh != NULL)
lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), MEM_LEAK, &ml); 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) { if (ml.chunks != 0) {
BIO_printf(b, "%ld bytes leaked in %d chunks\n", ml.bytes, ml.chunks); BIO_printf(b, "%ld bytes leaked in %d chunks\n", ml.bytes, ml.chunks);
#ifdef CRYPTO_MDEBUG_ABORT #ifdef CRYPTO_MDEBUG_ABORT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册