-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

According to https://www.openssl.org/docs/crypto/pem.html free the
memory before, otherwise cppcheck blames it b/c of :

[crypt_prog.cpp:366]: (error) Memory leak: rsa_key_
[crypt_prog.cpp:380]: (error) Memory leak: rsa_key_

- -- 
MfG/Sincerely
Toralf Förster
pgp finger print:1A37 6F99 4A9D 026F 13E2 4DCF C4EA CDDE 0076 E94E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlLaSkEACgkQxOrN3gB26U5ongD/fxxXWnlMalICBpavgjJQS8LG
gcnVfFXr4w3chA8ji/cA/iMIX/D6LVxiU+guD/k7NxDR/9VROwuo5V7i75K1JCa4
=jwCA
-----END PGP SIGNATURE-----
diff --git a/lib/crypt_prog.cpp b/lib/crypt_prog.cpp
index 3d45361..14a978a 100644
--- a/lib/crypt_prog.cpp
+++ b/lib/crypt_prog.cpp
@@ -363,6 +363,7 @@ int main(int argc, char** argv) {
             }
             if (kpriv) {
                 fpriv = fopen (argv[4], "r");
+		X509_free(rsa_key_);
                 rsa_key_ = PEM_read_RSAPrivateKey(fpriv, NULL, NULL, NULL);
                 fclose(fpriv);
                 if (rsa_key_ == NULL) {
@@ -377,6 +378,7 @@ int main(int argc, char** argv) {
                 print_key_hex(fpriv, (KEY*)&private_key, sizeof(private_key));
             } else {
                 fpub = fopen (argv[4], "r");
+		X509_free(rsa_key_);
                 rsa_key_ = PEM_read_RSA_PUBKEY(fpub, NULL, NULL, NULL);
                 fclose(fpub);
                 if (rsa_key_ == NULL) {

Attachment: free_rsa_key_before.patch.sig
Description: PGP signature

_______________________________________________
boinc_dev mailing list
boinc_dev@ssl.berkeley.edu
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.

Reply via email to