feat:[TD-32642] fix encode error

This commit is contained in:
wangmm0220 2024-12-06 00:54:28 +08:00
parent 0165684131
commit 0c25fccb8d
1 changed files with 2 additions and 4 deletions

View File

@ -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) { static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len) {
TAOS_CHECK_RETURN(tDecodeBinary(pCoder, (uint8_t**)val, len)); TAOS_CHECK_RETURN(tDecodeBinary(pCoder, (uint8_t**)val, len));
if (*len > 0) { (*len) -= 1; // *len = 0 - 1
(*len) -= 1;
}
return 0; return 0;
} }
@ -429,7 +427,7 @@ static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
uint32_t len; uint32_t len;
TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len)); TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len));
if (pCoder->pos + 1 < pCoder->size) { if (len < pCoder->size) {
TAOS_MEMCPY(val, pStr, len + 1); TAOS_MEMCPY(val, pStr, len + 1);
} }