提交 047c35a4 编写于 作者: H Haojun Liao

[ts-218] fix the invalid write.

上级 c7381f19
...@@ -112,14 +112,15 @@ void taosArrayRemoveBatch(SArray *pArray, const int32_t* pData, int32_t numOfEle ...@@ -112,14 +112,15 @@ void taosArrayRemoveBatch(SArray *pArray, const int32_t* pData, int32_t numOfEle
i += 1; i += 1;
} }
assert(i == pData[numOfElems - 1] + 1); assert(i == pData[numOfElems - 1] + 1 && i < size);
int32_t dstIndex = pData[numOfElems - 1] - numOfElems + 1;
int32_t srcIndex = pData[numOfElems - 1] + 1; int32_t srcIndex = pData[numOfElems - 1] + 1;
int32_t dstIndex = pData[numOfElems - 1] - numOfElems + 1;
char* dst = TARRAY_GET_ELEM(pArray, dstIndex); if (pArray->size - srcIndex > 0) {
char* src = TARRAY_GET_ELEM(pArray, srcIndex); char* dst = TARRAY_GET_ELEM(pArray, dstIndex);
memmove(dst, src, pArray->elemSize * (pArray->size - numOfElems)); char* src = TARRAY_GET_ELEM(pArray, srcIndex);
memmove(dst, src, pArray->elemSize * (pArray->size - srcIndex));
}
pArray->size -= numOfElems; pArray->size -= numOfElems;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册