From f945697f26f92bcd42f569868015d18ff04a1304 Mon Sep 17 00:00:00 2001 From: YeHuiSheng Date: Mon, 22 Jul 2019 17:15:27 +0800 Subject: [PATCH] Modify the strlen judgement to avoid memory leak. Change-Id: I4752ba24943b4c5e47e63b3c3e95811dec73ecce Closes-Bug: #1837344 Signed-off-by: YeHuiSheng --- mtce-common/src/common/msgClass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mtce-common/src/common/msgClass.cpp b/mtce-common/src/common/msgClass.cpp index 9f5bb78e..af284c25 100644 --- a/mtce-common/src/common/msgClass.cpp +++ b/mtce-common/src/common/msgClass.cpp @@ -285,8 +285,8 @@ int msgClassAddr::getAddressFromInterface(const char* interface, char* address, char *clstr_iface_name = NULL; get_clstr_iface(&clstr_iface_name); - if (clstr_iface_name && strlen(clstr_iface_name)) { - if (!strcmp(interface, clstr_iface_name)) { + if (clstr_iface_name) { + if (strlen(clstr_iface_name) && (!strcmp(interface, clstr_iface_name))) { if (!strcmp(clstr_iface_name, daemon_mgmnt_iface().data())) { // cluster-host and mgmt interface name are the same interface_type = MGMNT_IFACE;