From 0c25fccb8d51e7678717dc46b760a340777ab09f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 6 Dec 2024 00:54:28 +0800 Subject: [PATCH] feat:[TD-32642] fix encode error --- include/util/tencode.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/util/tencode.h b/include/util/tencode.h index efe3883d16..794844ed74 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -413,9 +413,7 @@ static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint3 static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len) { TAOS_CHECK_RETURN(tDecodeBinary(pCoder, (uint8_t**)val, len)); - if (*len > 0) { - (*len) -= 1; - } + (*len) -= 1; // *len = 0 - 1 return 0; } @@ -429,7 +427,7 @@ static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) { uint32_t len; TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len)); - if (pCoder->pos + 1 < pCoder->size) { + if (len < pCoder->size) { TAOS_MEMCPY(val, pStr, len + 1); }