If we hit the error path and create_ssl_ctx_pair has been passed a
pre-created SSL_CTX then we could end up with a double free.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11834)
return 1;
err:
- SSL_CTX_free(serverctx);
- SSL_CTX_free(clientctx);
+ if (*sctx == NULL)
+ SSL_CTX_free(serverctx);
+ if (cctx != NULL && *cctx == NULL)
+ SSL_CTX_free(clientctx);
return 0;
}