Martin Salo wrote:
Hello Mailinglist,
I have a RSA key written to memory. How can I free the memory?
oBIO = BIO_new(BIO_s_mem());
PEM_write_bio_RSAPrivateKey(oBIO, oRsaKey, 0, 0, 0, 0, 0);
char *cMem;
iBytesWritten = BIO_get_mem_data(oBIO, &cMem);
cMem[iBytesWritten] = '\0';
// #### How can I free cMem? ####
Regards
Martin
"BIO_get_mem_data() sets pp to a pointer to the start of the memory BIOs
data and returns the total amount of data available."
That means your cMem points to data inside the BIO. In other words, you
shouldn't be modifying cMem because that would modify the BIO data and
you are probably causing a buffer overrun (creating frustrating
application crash issues later on). Calling BIO_free() will also free
the memory associated with cMem.
--
Thomas Hruska
Shining Light Productions
Home of BMP2AVI, Nuclear Vision, ProtoNova, and Win32 OpenSSL.
http://www.slproweb.com/
Ask me about discounts on any Shining Light Productions product!
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]