Commit 024d681e authored by Todd Short's avatar Todd Short Committed by Rich Salz
Browse files

Skipping tests in evp_test leaks memory



When configured with "no-mdc2 enable-crypto-mdebug" the evp_test
will leak memory due to skipped tests, and error out.

Also fix a skip condition

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1968)
parent beacb0f0
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -351,10 +351,9 @@ static int setup_test(struct evp_test *t, const struct evp_test_method *tmeth)
    if (t->meth) {
        t->ntests++;
        if (t->skip) {
            t->meth = tmeth;
            t->nskip++;
            return 1;
        }
        } else {
            /* run the test */
            t->err = NULL;
            if (t->meth->run_test(t) != 1) {
                fprintf(stderr, "%s test error line %d\n",
@@ -366,10 +365,14 @@ static int setup_test(struct evp_test *t, const struct evp_test_method *tmeth)
                    ERR_print_errors_fp(stderr);
                t->errors++;
            }
        }
        /* clean it up */
        ERR_clear_error();
        if (t->data != NULL) {
            t->meth->cleanup(t);
            OPENSSL_free(t->data);
            t->data = NULL;
        }
        OPENSSL_free(t->expected_err);
        t->expected_err = NULL;
        free_expected(t);
@@ -1212,9 +1215,7 @@ static int pkey_test_init(struct evp_test *t, const char *name,
        rv = find_key(&pkey, name, t->public);
    if (!rv)
        rv = find_key(&pkey, name, t->private);
    if (!rv)
        return 0;
    if (!pkey) {
    if (!rv || pkey == NULL) {
        t->skip = 1;
        return 1;
    }