From 26dada6140374b5677bf5663ab6c4fb070ad5a6a Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Sat, 20 Apr 2024 11:21:09 +0800 Subject: [PATCH] fix memory leak. Signed-off-by: dingxiaochen --- services/vendor/src/at_sms.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/vendor/src/at_sms.c b/services/vendor/src/at_sms.c index 9c2a453f..d5d74882 100644 --- a/services/vendor/src/at_sms.c +++ b/services/vendor/src/at_sms.c @@ -200,10 +200,6 @@ void ReqSendCdmaSms(const ReqDataInfo *requestInfo, const char *data, size_t dat FreeResponseInfo(responseInfo); return; } - responseInfo = (ResponseInfo *)malloc(sizeof(ResponseInfo)); - if (responseInfo == NULL) { - err = HRIL_ERR_GENERIC_FAILURE; - } err = SendCommandLock("AT+COPS?", "COPS?", 0, &responseInfo); if (err != 0 || (responseInfo != NULL && !responseInfo->success)) { TELEPHONY_LOGE("AT+COPS? send failed"); @@ -271,6 +267,9 @@ static void WriteSimMessage(const ReqDataInfo *requestInfo, const HRilSmsWriteSm } msg = ((HRilSmsWriteSms *)data); if (msg->smsc == NULL || (strcmp(msg->smsc, "") == 0)) { + if (msg->smsc != NULL) { + free(msg->smsc); + } msg->smsc = (char *)malloc(strlen("00") + 1); if (strcpy_s(msg->smsc, strlen("00") + 1, "00") != EOK) { TELEPHONY_LOGE("Set smsc failed"); @@ -369,6 +368,9 @@ bool CheckSimMessageValid( return false; } if (msg->smsc == NULL || (strcmp(msg->smsc, "") == 0)) { + if (msg->smsc != NULL) { + free(msg->smsc); + } msg->smsc = (char *)malloc(strlen("00") + 1); if (strcpy_s(msg->smsc, strlen("00") + 1, "00") != EOK) { TELEPHONY_LOGE("Set smsc failed");