From ad329ec442969721286002b7beb9d0f19f39a3c8 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 13 Jul 2022 11:51:16 +0900 Subject: [PATCH] Fix memory issues in unittest code Change-Id: Ifbac73ef284ce1fd96c7097356b5aa52c57fd2ba Signed-off-by: Jaehyun Kim --- unittest/tct-connection-core.cpp | 1 + unittest/utc-connection-profile.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/unittest/tct-connection-core.cpp b/unittest/tct-connection-core.cpp index 674372a..6de1c5a 100755 --- a/unittest/tct-connection-core.cpp +++ b/unittest/tct-connection-core.cpp @@ -79,6 +79,7 @@ TEST(connection, connection){ } else { PRINT_LOG(DLOG_INFO, "NativeTCT", "Name check error! [%s][%s]", pszGetTCName, tc_array[i].name); + FREE_MEMORY_TC(pszGetTCName); ASSERT_EQ(0, 1); } if (COMMON_DEBUG) diff --git a/unittest/utc-connection-profile.c b/unittest/utc-connection-profile.c index 28fa478..bebc587 100755 --- a/unittest/utc-connection-profile.c +++ b/unittest/utc-connection-profile.c @@ -1989,7 +1989,10 @@ int utc_connection_profile_get_cellular_auth_info_p(void) char *pwd = NULL; int ret = connection_profile_get_cellular_auth_info(profile_cellular, &type, &name, &pwd); - FREE_RESOURCE(name); FREE_RESOURCE(pwd); + if (ret == CONNECTION_ERROR_NONE) { + FREE_RESOURCE(name); + FREE_RESOURCE(pwd); + } if (telephony_supported) CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_NONE); -- 2.7.4