From 61ac6b849967fc384e8e51a5c94aa016a2449bed Mon Sep 17 00:00:00 2001 From: sima Date: Tue, 13 Aug 2024 14:35:33 +0800 Subject: [PATCH] fix:[TD-31402] Fix memory leak. --- source/client/src/clientSmlJson.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/client/src/clientSmlJson.c b/source/client/src/clientSmlJson.c index 14d6a95e22..10ff234552 100644 --- a/source/client/src/clientSmlJson.c +++ b/source/client/src/clientSmlJson.c @@ -746,7 +746,13 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo int64_t ts = smlParseTSFromJSON(info, tsJson); if (unlikely(ts < 0)) { char* tmp = cJSON_PrintUnformatted(tsJson); - uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload %s %s %" PRId64, info->id, info->msgBuf.buf,tmp, ts); + if (tmp == NULL) { + uError("cJSON_PrintUnformatted failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload %s %" PRId64, info->id, info->msgBuf.buf, ts); + } else { + uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload %s %s %" PRId64, info->id, info->msgBuf.buf,tmp, ts); + taosMemoryFree(tmp); + } return TSDB_CODE_INVALID_TIMESTAMP; } SSmlKv kvTs = {0};