diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2017-02-19 18:12:03 +0100 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-02-21 14:13:58 -0500 |
commit | 9ad52c562a93c9a57ae3024e54c575430753244c (patch) | |
tree | 0876289c798ee32c2c5cb272bc0ee761a1a054af /apps | |
parent | a7c04f2b540cce99055326a3ab932032bdf48cf5 (diff) |
Fix a few memleaks in TXT_DB.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2684)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/ca.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1836,10 +1836,8 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, } irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row space"); - for (i = 0; i < DB_NUMBER; i++) { + for (i = 0; i < DB_NUMBER; i++) irow[i] = row[i]; - row[i] = NULL; - } irow[DB_NUMBER] = NULL; if (!TXT_DB_insert(db->db, irow)) { @@ -1847,10 +1845,14 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error); goto end; } + irow = NULL; ok = 1; end: - for (i = 0; i < DB_NUMBER; i++) - OPENSSL_free(row[i]); + if (irow != NULL) { + for (i = 0; i < DB_NUMBER; i++) + OPENSSL_free(row[i]); + OPENSSL_free(irow); + } X509_NAME_free(CAname); X509_NAME_free(subject); |