Change memory poisoning flag to a count
This allows unusually-nested memory poisoning to work correctly, since
it keeps track of whether any buffers are still poisoned, rather than
just disabling poisoning at the first call to the UNPOISON() macro.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/tests/src/test_memory.c b/tests/src/test_memory.c
index dbb7b20..ac9dde6 100644
--- a/tests/src/test_memory.c
+++ b/tests/src/test_memory.c
@@ -20,7 +20,7 @@
#if defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
-_Thread_local int mbedtls_test_memory_poisoning_enabled = 0;
+_Thread_local unsigned int mbedtls_test_memory_poisoning_count = 0;
static void align_for_asan(const unsigned char **p_ptr, size_t *p_size)
{
@@ -39,7 +39,7 @@
void mbedtls_test_memory_poison(const unsigned char *ptr, size_t size)
{
- if (!mbedtls_test_memory_poisoning_enabled) {
+ if (mbedtls_test_memory_poisoning_count == 0) {
return;
}
if (size == 0) {