Skip to content

Commit f878c43

Browse files
committed
wolfcrypt/src/wc_port.c: in wolfCrypt_Cleanup(), return error if called with initRefCount <= 0.
1 parent 627f516 commit f878c43

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

wolfcrypt/src/wc_port.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,16 @@ int wolfCrypt_Cleanup(void)
576576
#endif
577577

578578
(void)wolfSSL_Atomic_Int_SubFetch(&initRefCount, 1);
579-
}
580579

581580
#if defined(HAVE_LIBOQS)
582-
wolfSSL_liboqsClose();
581+
wolfSSL_liboqsClose();
583582
#endif
583+
}
584+
else if (my_initRefCount < 0) {
585+
(void)wolfSSL_Atomic_Int_AddFetch(&initRefCount, 1);
586+
WOLFSSL_MSG("wolfCrypt_Cleanup() called with initRefCount <= 0.");
587+
ret = ALREADY_E;
588+
}
584589

585590
return ret;
586591
}

0 commit comments

Comments
 (0)