From 48533ebab413186a76e89d4262e9feebaee587c2 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Wed, 30 Mar 2022 10:09:07 +0800 Subject: [PATCH] fix memory core dump of wrong ucs-4 size --- src/client/src/tscUtil.c | 3 ++- tests/script/general/compute/str_char_length.sim | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 6fb7a645e0..8bad157881 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -991,7 +991,8 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI continue; } int32_t len = 0; - taosMbsToUcs4(varDataVal(srcRow), varDataLen(srcRow), varDataVal(dstRow), bytes, &len); + taosMbsToUcs4(varDataVal(srcRow), varDataLen(srcRow), varDataVal(dstRow), + bytes-VARSTR_HEADER_SIZE, &len); varDataLen(dstRow) = len; } memcpy(srcData, dstData, bytes*rows); diff --git a/tests/script/general/compute/str_char_length.sim b/tests/script/general/compute/str_char_length.sim index 5ef295db88..97365867d9 100644 --- a/tests/script/general/compute/str_char_length.sim +++ b/tests/script/general/compute/str_char_length.sim @@ -1024,7 +1024,7 @@ if $data60 != @10@ then endi print execute sql select char_length(c15) from (select * from stb1); sql select char_length(c15) from (select * from stb1); -if $data00 != @0@ then +if $data00 != @1@ then return -1 endi if $data10 != @NULL@ then @@ -1033,25 +1033,25 @@ endi if $data20 != @NULL@ then return -1 endi -if $data30 != @0@ then +if $data30 != @1@ then return -1 endi -if $data40 != @0@ then +if $data40 != @1@ then return -1 endi -if $data50 != @0@ then +if $data50 != @3@ then return -1 endi if $data60 != @0@ then return -1 endi -if $data70 != @0@ then +if $data70 != @1@ then return -1 endi -if $data80 != @0@ then +if $data80 != @1@ then return -1 endi -if $data90 != @0@ then +if $data90 != @1@ then return -1 endi print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); -- GitLab