From 342843884a68a480aaa8fa5c2767c3a9a2a38bf8 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Sun, 19 Feb 2017 20:47:45 +0100 Subject: [PATCH] Fix some more memory leaks with TXT_DB_insert. Reviewed-by: Richard Levitte Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/2685) --- apps/ca.c | 8 +++++--- apps/srp.c | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/ca.c b/apps/ca.c index b9a66abccf..f90f033bae 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -2397,18 +2397,20 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value) goto err; } - 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)) { BIO_printf(bio_err, "failed to update database\n"); BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error); + OPENSSL_free(irow); goto err; } + for (i = 0; i < DB_NUMBER; i++) + row[i] = NULL; + /* Revoke Certificate */ if (type == -1) ok = 1; diff --git a/apps/srp.c b/apps/srp.c index 37341a5d20..ce01a24f2a 100644 --- a/apps/srp.c +++ b/apps/srp.c @@ -183,10 +183,8 @@ static int update_index(CA_DB *db, BIO *bio, char **row) return 0; } - 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)) { -- 2.25.1