NULL tofree when it is freed to avoid double free.
authorDr. Stephen Henson <steve@openssl.org>
Thu, 9 Jan 2003 13:05:57 +0000 (13:05 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 9 Jan 2003 13:05:57 +0000 (13:05 +0000)
Make sure key is not NULL before freeing it.

apps/ca.c

index 93e61f610b44643cd66dd835acbb0d88f4d1b85e..5b490c80ec81bd4a28bbda9dcdbcf809275190b4 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -76,6 +76,8 @@
 #include <openssl/ocsp.h>
 #include <openssl/pem.h>
 
+#include <dmalloc.h>
+
 #ifdef OPENSSL_SYS_WINDOWS
 #define strcasecmp _stricmp
 #else
@@ -597,7 +599,10 @@ bad:
                goto err;
                }
        if(tofree)
+               {
                OPENSSL_free(tofree);
+               tofree = NULL;
+               }
 
        if (!load_config(bio_err, conf))
                goto err;
@@ -1637,7 +1642,7 @@ err:
 
        if (ret) ERR_print_errors(bio_err);
        app_RAND_write_file(randfile, bio_err);
-       if (free_key)
+       if (free_key && key)
                OPENSSL_free(key);
        BN_free(serial);
        TXT_DB_free(db);