Memory leaks in d2i_X509_CRL and X509_CRL_free?

2012-10-26 Thread Zhuang Yuyao
Hi,

I'm testing loading a large CRL file into a X509_CRL structure then
free it. but after X509_CRL_free, there are still some mysterious
memory consumption.

pmap reports that total memory consumption is 105608KB right after the
CRL file was loaded, and 88920K after X509_CRL_free was called.

here is my test code:
// gcc -o a -g a.c
// ./a testcrl.pem
// the crl file size is about 30M bytes, and itsformat is PEM

#include stdio.h
#include string.h
#include sys/time.h
#include time.h
#include sys/syslog.h
#include errno.h
#include sys/vfs.h
#include errno.h
#define _GNU_SOURCE 1
#include math.h
#include stdlib.h
#include unistd.h
#include openssl/objects.h
#include openssl/evp.h
#include openssl/x509.h
#include openssl/bio.h
#include openssl/pem.h

void test4(const char* filename) {
X509_CRL* crl = NULL;
BIO* in = NULL;

in = BIO_new_file(filename, r);
if (!in) {
return;
}
crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
if (!crl) {
BIO_reset(in);
crl = d2i_X509_CRL_bio(in, NULL);
}
BIO_free(in);
 // pmap: total  105608K
if (crl) {
X509_CRL_free(crl);
//  pmap: total  88920K
}
}

int main(int argc, char* argv[]) {
test4(argv[1]);
return 0;
}

I am wondering why not all of the memory are freed, and how can I free
those lost memory.

Thanks very much.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Memory leaks in d2i_X509_CRL and X509_CRL_free?

2012-10-26 Thread Zhuang Yuyao
the openssl library version is 1.0.1c, the operation system is debian linux.

On Fri, Oct 26, 2012 at 8:05 PM, Zhuang Yuyao mli...@gmail.com wrote:
 Hi,

 I'm testing loading a large CRL file into a X509_CRL structure then
 free it. but after X509_CRL_free, there are still some mysterious
 memory consumption.

 pmap reports that total memory consumption is 105608KB right after the
 CRL file was loaded, and 88920K after X509_CRL_free was called.

 here is my test code:
 // gcc -o a -g a.c
 // ./a testcrl.pem
 // the crl file size is about 30M bytes, and itsformat is PEM

 #include stdio.h
 #include string.h
 #include sys/time.h
 #include time.h
 #include sys/syslog.h
 #include errno.h
 #include sys/vfs.h
 #include errno.h
 #define _GNU_SOURCE 1
 #include math.h
 #include stdlib.h
 #include unistd.h
 #include openssl/objects.h
 #include openssl/evp.h
 #include openssl/x509.h
 #include openssl/bio.h
 #include openssl/pem.h

 void test4(const char* filename) {
 X509_CRL* crl = NULL;
 BIO* in = NULL;

 in = BIO_new_file(filename, r);
 if (!in) {
 return;
 }
 crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
 if (!crl) {
 BIO_reset(in);
 crl = d2i_X509_CRL_bio(in, NULL);
 }
 BIO_free(in);
  // pmap: total  105608K
 if (crl) {
 X509_CRL_free(crl);
 //  pmap: total  88920K
 }
 }

 int main(int argc, char* argv[]) {
 test4(argv[1]);
 return 0;
 }

 I am wondering why not all of the memory are freed, and how can I free
 those lost memory.

 Thanks very much.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org