diff --git a/tests/api.c b/tests/api.c index b6037309da..635eff2096 100644 --- a/tests/api.c +++ b/tests/api.c @@ -33583,7 +33583,10 @@ static int test_lms_write_key(const byte* priv, word32 privSz, void* context) FILE* f = fopen((const char*)context, "wb"); if (f == NULL) return -1; - fwrite(priv, 1, privSz, f); + if (fwrite(priv, 1, privSz, f) != privSz) { + fclose(f); + return -1; + } fclose(f); return WC_LMS_RC_SAVED_TO_NV_MEMORY; }