提交 5b7ec8ad 编写于 作者: X Xiaoyu Wang

fix: invalid write memory when query policy is 4

上级 5545bb80
...@@ -35,15 +35,15 @@ ...@@ -35,15 +35,15 @@
memcpy(&((pDst)->fldname), &((pSrc)->fldname), size); \ memcpy(&((pDst)->fldname), &((pSrc)->fldname), size); \
} while (0) } while (0)
#define COPY_CHAR_POINT_FIELD(fldname) \ #define COPY_CHAR_POINT_FIELD(fldname) \
do { \ do { \
if (NULL == (pSrc)->fldname) { \ if (NULL == (pSrc)->fldname) { \
break; \ break; \
} \ } \
(pDst)->fldname = taosStrdup((pSrc)->fldname); \ (pDst)->fldname = taosStrdup((pSrc)->fldname); \
if (NULL == (pDst)->fldname) { \ if (NULL == (pDst)->fldname) { \
return TSDB_CODE_OUT_OF_MEMORY; \ return TSDB_CODE_OUT_OF_MEMORY; \
} \ } \
} while (0) } while (0)
#define CLONE_NODE_FIELD(fldname) \ #define CLONE_NODE_FIELD(fldname) \
...@@ -158,7 +158,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { ...@@ -158,7 +158,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY: { case TSDB_DATA_TYPE_VARBINARY: {
int32_t len = varDataTLen(pSrc->datum.p) + 1; int32_t len = pSrc->node.resType.bytes + 1;
pDst->datum.p = taosMemoryCalloc(1, len); pDst->datum.p = taosMemoryCalloc(1, len);
if (NULL == pDst->datum.p) { if (NULL == pDst->datum.p) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
......
...@@ -3269,7 +3269,7 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { ...@@ -3269,7 +3269,7 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY: { case TSDB_DATA_TYPE_VARBINARY: {
pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + VARSTR_HEADER_SIZE + 1); pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1);
if (NULL == pNode->datum.p) { if (NULL == pNode->datum.p) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
break; break;
......
...@@ -928,7 +928,7 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) { ...@@ -928,7 +928,7 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) {
code = TSDB_CODE_FAILED; code = TSDB_CODE_FAILED;
break; break;
} }
pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + VARSTR_HEADER_SIZE + 1); pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1);
if (NULL == pNode->datum.p) { if (NULL == pNode->datum.p) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
break; break;
......
...@@ -2101,9 +2101,9 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) { ...@@ -2101,9 +2101,9 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY: case TSDB_DATA_TYPE_VARBINARY:
pVal->pz = taosMemoryMalloc(pVal->nLen + VARSTR_HEADER_SIZE + 1); pVal->pz = taosMemoryMalloc(pVal->nLen + 1);
memcpy(pVal->pz, pNode->datum.p, pVal->nLen + VARSTR_HEADER_SIZE); memcpy(pVal->pz, pNode->datum.p, pVal->nLen);
pVal->pz[pVal->nLen + VARSTR_HEADER_SIZE] = 0; pVal->pz[pVal->nLen] = 0;
break; break;
case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_JSON:
pVal->nLen = getJsonValueLen(pNode->datum.p); pVal->nLen = getJsonValueLen(pNode->datum.p);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册