From: Bernd Edlinger Date: Sun, 19 Feb 2017 19:47:45 +0000 (+0100) Subject: Fix some more memory leaks with TXT_DB_insert. X-Git-Tag: OpenSSL_1_0_2l~83 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=342843884a68a480aaa8fa5c2767c3a9a2a38bf8;p=oweals%2Fopenssl.git 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) --- 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)) {