From 67c7a11b8fc4a5c723c664d4b4d7f23a77357167 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Thu, 18 Jun 2026 17:23:11 -0600 Subject: [PATCH] fix for nightly memory allocation test cases with LMS --- tests/api/test_lms_xmss.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/api/test_lms_xmss.c b/tests/api/test_lms_xmss.c index e99a92d489..1eac4b2dba 100644 --- a/tests/api/test_lms_xmss.c +++ b/tests/api/test_lms_xmss.c @@ -118,7 +118,9 @@ int test_wc_LmsKey_sign_verify(void) int i; int numSigs = 5; + /* Zero so cleanup is safe if an early alloc failure skips init. */ XMEMSET(&key, 0, sizeof(key)); + XMEMSET(&rng, 0, sizeof(rng)); ExpectIntEQ(wc_InitRng(&rng), 0); @@ -174,8 +176,10 @@ int test_wc_LmsKey_reload_cache(void) /* Sign 33 times to advance q past the 32-entry cache window. */ int preSigs = 33; + /* Zero so cleanup is safe if an early alloc failure skips init. */ XMEMSET(&key, 0, sizeof(key)); XMEMSET(&vkey, 0, sizeof(vkey)); + XMEMSET(&rng, 0, sizeof(rng)); ExpectIntEQ(wc_InitRng(&rng), 0); @@ -862,7 +866,8 @@ static int rfc9802_gen_chain(void* caKey, int caKeyType, int caSigType, ExpectNotNull(leafDer = (byte*)XMALLOC(derCap, NULL, DYNAMIC_TYPE_TMP_BUFFER)); ExpectIntEQ(wc_ecc_init(&leafKey), 0); - leafKeyInit = 1; + if (EXPECT_SUCCESS()) /* only flag for free if init ran and succeeded */ + leafKeyInit = 1; ExpectIntEQ(wc_ecc_make_key(rng, 32, &leafKey), 0); /* Self-signed CA root. */ @@ -972,6 +977,10 @@ int test_rfc9802_lms_x509_gen(void) LmsKey key; WC_RNG rng; + /* Zero so cleanup is safe if an early alloc failure skips init. */ + XMEMSET(&key, 0, sizeof(key)); + XMEMSET(&rng, 0, sizeof(rng)); + ExpectIntEQ(wc_InitRng(&rng), 0); /* Single-level LMS (L1-H5-W8). */ @@ -1177,6 +1186,10 @@ int test_rfc9802_xmss_x509_gen(void) XmssKey key; WC_RNG rng; + /* Zero so cleanup is safe if an early alloc failure skips init. */ + XMEMSET(&key, 0, sizeof(key)); + XMEMSET(&rng, 0, sizeof(rng)); + ExpectIntEQ(wc_InitRng(&rng), 0); /* Single-tree XMSS. */