未验证 提交 b8fe575a 编写于 作者: H Haojun Liao 提交者: GitHub

Merge pull request #20068 from taosdata/fix/TD-22624

fix:compare func for topic & double free in taosArrayRemoveDuplicate…
......@@ -658,7 +658,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
} else {
char *oldTopic = taosArrayGetP(pConsumerOld->currentTopics, i);
char *newTopic = taosArrayGetP(newSub, j);
int comp = compareLenPrefixedStr(oldTopic, newTopic);
int comp = strcmp(oldTopic, newTopic);
if (comp == 0) {
i++;
j++;
......
......@@ -139,6 +139,7 @@ void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)
}
taosArraySet(pArray, pos + 1, p2);
memset(TARRAY_GET_ELEM(pArray, i), 0, pArray->elemSize);
pos += 1;
} else {
pos += 1;
......@@ -171,12 +172,13 @@ void taosArrayRemoveDuplicateP(SArray* pArray, __compar_fn_t comparFn, void (*fp
// do nothing
} else {
if (pos + 1 != i) {
void* p = taosArrayGet(pArray, pos + 1);
void* p = taosArrayGetP(pArray, pos + 1);
if (fp != NULL) {
fp(p);
}
taosArraySet(pArray, pos + 1, p2);
memset(TARRAY_GET_ELEM(pArray, i), 0, pArray->elemSize);
pos += 1;
} else {
pos += 1;
......
......@@ -1232,7 +1232,7 @@ int32_t taosArrayCompareString(const void *a, const void *b) {
const char *x = *(const char **)a;
const char *y = *(const char **)b;
return compareLenPrefixedStr(x, y);
return strcmp(x, y);
}
int32_t comparestrPatternMatch(const void *pLeft, const void *pRight) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册