Fix a possible memleak in apps/rehash.c
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 3 Dec 2023 10:29:52 +0000 (11:29 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 12 Dec 2023 18:49:23 +0000 (19:49 +0100)
The OPENSSL_DIR_end was missing in case of error.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22920)

(cherry picked from commit 01709fcb8b609cfc47e277d20492c333bafb113e)

apps/rehash.c

index d63a0909a2bbc98bc85820dd2112abf94bd62619..85eee3857942dd46a240c68cbb818171c38ab5db 100644 (file)
@@ -383,6 +383,7 @@ static int do_dir(const char *dirname, enum Hash h)
         if ((copy = OPENSSL_strdup(filename)) == NULL
                 || sk_OPENSSL_STRING_push(files, copy) == 0) {
             OPENSSL_free(copy);
+            OPENSSL_DIR_end(&d);
             BIO_puts(bio_err, "out of memory\n");
             errs = 1;
             goto err;