Merge pull request #24025 from taosdata/fix/case-when-heap-overflow

fix:heap overflow if print json value node
This commit is contained in:
dapan1121 2023-12-12 09:20:12 +08:00 committed by GitHub
commit 394dc6c725
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1367,8 +1367,8 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
} else { } else {
int32_t type = output.columnData->info.type; int32_t type = output.columnData->info.type;
if (IS_VAR_DATA_TYPE(type)) { // todo refactor if (IS_VAR_DATA_TYPE(type)) { // todo refactor
res->datum.p = output.columnData->pData; res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData) + 1, sizeof(char)); // add \0 to the end for print json value
output.columnData->pData = NULL; memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
} else { } else {
nodesSetValueNodeValue(res, output.columnData->pData); nodesSetValueNodeValue(res, output.columnData->pData);
} }