From: tb Date: Sun, 4 Apr 2021 19:32:26 +0000 (+0000) Subject: Don't leak key and dh in the error path. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=71e2539cf3301d6f51f18edb8d9759d17ae07502;p=openbsd Don't leak key and dh in the error path. --- diff --git a/regress/lib/libcrypto/bn/mont/mont.c b/regress/lib/libcrypto/bn/mont/mont.c index 30d5317b646..83d56e53757 100644 --- a/regress/lib/libcrypto/bn/mont/mont.c +++ b/regress/lib/libcrypto/bn/mont/mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mont.c,v 1.2 2014/10/22 13:23:05 jsing Exp $ */ +/* $OpenBSD: mont.c,v 1.3 2021/04/04 19:32:26 tb Exp $ */ /* * Copyright (c) 2014 Miodrag Vallat. @@ -34,8 +34,9 @@ int main(int argc, char *argv[]) { - DH *dh; - unsigned char *key, r[32 + 16 * 8]; + DH *dh = NULL; + unsigned char *key = NULL; + unsigned char r[32 + 16 * 8]; size_t privsz; arc4random_buf(r, sizeof(r)); @@ -67,7 +68,9 @@ main(int argc, char *argv[]) return 0; -err: + err: ERR_print_errors_fp(stderr); + free(key); + DH_free(dh); return 1; }