Fix bogus free() hazard in service framework tests
In the service framework tests, the common teardown function
calls direct_caller_deinit to clean-up. In normal cases,
this will result in buffers used by the direct caller
being freed. If a test assertion results in a test exit
without calling direct_caller_init, there is the hazard
that free will be called with uninitialized buffer pointers.
This change removes this hazard by initializing the direct_caller
structure to zero in the common setup method.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I635490991c6d2e6c00d44053b77d6c38f2446a73
diff --git a/components/service/common/provider/test/service_framework_tests.cpp b/components/service/common/provider/test/service_framework_tests.cpp
index e4afb18..afcbffa 100644
--- a/components/service/common/provider/test/service_framework_tests.cpp
+++ b/components/service/common/provider/test/service_framework_tests.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -44,7 +44,7 @@
void setup()
{
- memset(&m_direct_caller, sizeof(m_direct_caller), 0);
+ memset(&m_direct_caller, 0, sizeof(m_direct_caller));
}
void teardown()