diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 179fbd05a5a8f5ddfb28b68130f87e26ed4e522f..4bed561f71aef6aafcf4ec2af814c0a2c7e6b63f 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -417,14 +417,20 @@ int32_t compareFindItemInSet(const void *pLeft, const void* pRight) { int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { SPatternCompareInfo pInfo = {'%', '_'}; + size_t size = varDataLen(pLeft)/TSDB_NCHAR_SIZE; assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE); wchar_t *pattern = calloc(varDataLen(pRight) + 1, sizeof(wchar_t)); + wchar_t *str = calloc(size + 1, sizeof(wchar_t)); + memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); + memcpy(str, varDataVal(pLeft), size * sizeof(wchar_t)); + + int32_t ret = WCSPatternMatch(pattern, str, size, &pInfo); - int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo); free(pattern); + free(str); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; }