From ca1a991de57d013e7f9ac828004dc36572bd9425 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Wed, 26 Aug 2020 22:17:22 -0500 Subject: [PATCH] wolfcrypt/test/test.c: fix an error-path leak in dh_test(), and deal with possible -Wdeclaration-after-statement for `XFILE file`. --- wolfcrypt/test/test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 4cfa17375..9dff5d22b 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -14577,15 +14577,17 @@ static int dh_test(void) #elif defined(NO_ASN) /* don't use file, no DER parsing */ #elif !defined(NO_FILESYSTEM) - XFILE file = XFOPEN(dhParamsFile, "rb"); - if (!file) - ERROR_OUT(-7900, done); + { + XFILE file = XFOPEN(dhParamsFile, "rb"); + if (! file) + ERROR_OUT(-7900, done); - bytes = (word32) XFREAD(tmp, 1, DH_TEST_TMP_SIZE, file); - XFCLOSE(file); + bytes = (word32) XFREAD(tmp, 1, DH_TEST_TMP_SIZE, file); + XFCLOSE(file); + } #else /* No DH key to use. */ - return -7901; + ERROR_OUT(-7901, done); #endif /* USE_CERT_BUFFERS */ (void)idx;