diff --git a/services/implementation/src/dependency/hichain/mine_hichain_connector.cpp b/services/implementation/src/dependency/hichain/mine_hichain_connector.cpp index 44e54a941f1cb018521bcd7d9f056bc4bab765e0..c5d37fd50aac4b2f6818743904e4690487f839f6 100644 --- a/services/implementation/src/dependency/hichain/mine_hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/mine_hichain_connector.cpp @@ -143,6 +143,7 @@ int32_t MineHiChainConnector::DeleteCredentialAndGroup(void) LOGE("failed to delete hichain credential and group with ret:%{public}d.", retValue); return ERR_DM_FAILED; } + g_deviceGroupManager->destroyInfo(&returnInfo); #endif return DM_OK; } @@ -263,9 +264,11 @@ int MineHiChainConnector::ImportCredential(std::string reqJsonStr, std::string & } if (CreateGroup(reqJsonStr) != DM_OK) { DeleteCredentialAndGroup(); + g_deviceGroupManager->destroyInfo(&returnInfo); LOGE("fail to import hichain credential bacause create group unsuccessfully."); return ERR_DM_HICHAIN_GROUP_CREATE_FAILED; } + g_deviceGroupManager->destroyInfo(&returnInfo); #endif LOGI("import device credential info successfully."); return DM_OK; diff --git a/services/implementation/src/dependency/softbus/softbus_connector.cpp b/services/implementation/src/dependency/softbus/softbus_connector.cpp index 8bdbf7e2ef3ca7cc34fb3308348556abc81084a9..acd632078b4fb1fd811c642e0cb20623a4ba9cb8 100644 --- a/services/implementation/src/dependency/softbus/softbus_connector.cpp +++ b/services/implementation/src/dependency/softbus/softbus_connector.cpp @@ -639,9 +639,11 @@ std::string SoftbusConnector::GetNetworkIdByDeviceId(const std::string &deviceId LOGE("[SOFTBUS]GetNodeKeyInfo failed."); } if (reinterpret_cast(mUdid) == deviceId) { + FreeNodeInfo(nodeInfo); return static_cast(nodeBasicInfo->networkId); } } + FreeNodeInfo(nodeInfo); return ""; } @@ -714,10 +716,12 @@ bool SoftbusConnector::CheckIsOnline(const std::string &targetDeviceId) std::string udid = reinterpret_cast(mUdid); if (udid == targetDeviceId) { LOGI("The device is online."); + FreeNodeInfo(nodeInfo); return true; } } LOGI("The device is not online."); + FreeNodeInfo(nodeInfo); return false; } @@ -734,6 +738,7 @@ DmDeviceInfo SoftbusConnector::GetDeviceInfoByDeviceId(const std::string &device char deviceIdHash[DM_MAX_DEVICE_ID_LEN] = {0}; if (Crypto::GetUdidHash(deviceId, reinterpret_cast(deviceIdHash)) != DM_OK) { LOGE("get deviceIdHash by deviceId: %{public}s failed.", GetAnonyString(deviceId).c_str()); + FreeNodeInfo(nodeInfo); return info; } for (int32_t i = 0; i < deviceCount; ++i) { @@ -742,6 +747,7 @@ DmDeviceInfo SoftbusConnector::GetDeviceInfoByDeviceId(const std::string &device if (GetNodeKeyInfo(DM_PKG_NAME, nodeBasicInfo->networkId, NodeDeviceInfoKey::NODE_KEY_UDID, mUdid, sizeof(mUdid)) != DM_OK) { LOGE("[SOFTBUS]GetNodeKeyInfo failed."); + FreeNodeInfo(nodeInfo); return info; } std::string udid = reinterpret_cast(mUdid);