未验证 提交 e1b01e04 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #7632 from taosdata/fix/TD-6356

[TD-6356]<fix>: Fix the crash in TS-187
...@@ -3474,19 +3474,19 @@ void filterPrepare(void* expr, void* param) { ...@@ -3474,19 +3474,19 @@ void filterPrepare(void* expr, void* param) {
if (pInfo->optr == TSDB_RELATION_IN) { if (pInfo->optr == TSDB_RELATION_IN) {
int dummy = -1; int dummy = -1;
SHashObj *pObj = NULL; SHashObj *pObj = NULL;
if (pInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) { if (pInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
pObj = taosHashInit(256, taosGetDefaultHashFunction(pInfo->sch.type), true, false); pObj = taosHashInit(256, taosGetDefaultHashFunction(pInfo->sch.type), true, false);
SArray *arr = (SArray *)(pCond->arr); SArray *arr = (SArray *)(pCond->arr);
for (size_t i = 0; i < taosArrayGetSize(arr); i++) { for (size_t i = 0; i < taosArrayGetSize(arr); i++) {
char* p = taosArrayGetP(arr, i); char* p = taosArrayGetP(arr, i);
strtolower(varDataVal(p), varDataVal(p)); strntolower_s(varDataVal(p), varDataVal(p), varDataLen(p));
taosHashPut(pObj, varDataVal(p),varDataLen(p), &dummy, sizeof(dummy)); taosHashPut(pObj, varDataVal(p), varDataLen(p), &dummy, sizeof(dummy));
} }
} else { } else {
buildFilterSetFromBinary((void **)&pObj, pCond->pz, pCond->nLen); buildFilterSetFromBinary((void **)&pObj, pCond->pz, pCond->nLen);
} }
pInfo->q = (char *)pObj; pInfo->q = (char *)pObj;
} else if (pCond != NULL) { } else if (pCond != NULL) {
uint32_t size = pCond->nLen * TSDB_NCHAR_SIZE; uint32_t size = pCond->nLen * TSDB_NCHAR_SIZE;
if (size < (uint32_t)pSchema->bytes) { if (size < (uint32_t)pSchema->bytes) {
......
...@@ -32,6 +32,7 @@ char * strnchr(char *haystack, char needle, int32_t len, bool skipquote); ...@@ -32,6 +32,7 @@ char * strnchr(char *haystack, char needle, int32_t len, bool skipquote);
char ** strsplit(char *src, const char *delim, int32_t *num); char ** strsplit(char *src, const char *delim, int32_t *num);
char * strtolower(char *dst, const char *src); char * strtolower(char *dst, const char *src);
char * strntolower(char *dst, const char *src, int32_t n); char * strntolower(char *dst, const char *src, int32_t n);
char * strntolower_s(char *dst, const char *src, int32_t n);
int64_t strnatoi(char *num, int32_t len); int64_t strnatoi(char *num, int32_t len);
char * strbetween(char *string, char *begin, char *end); char * strbetween(char *string, char *begin, char *end);
char * paGetToken(char *src, char **token, int32_t *tokenLen); char * paGetToken(char *src, char **token, int32_t *tokenLen);
......
...@@ -202,7 +202,7 @@ char* strntolower(char *dst, const char *src, int32_t n) { ...@@ -202,7 +202,7 @@ char* strntolower(char *dst, const char *src, int32_t n) {
if (n == 0) { if (n == 0) {
*p = 0; *p = 0;
return dst; return dst;
} }
for (c = *src++; n-- > 0; c = *src++) { for (c = *src++; n-- > 0; c = *src++) {
if (esc) { if (esc) {
esc = 0; esc = 0;
...@@ -224,6 +224,26 @@ char* strntolower(char *dst, const char *src, int32_t n) { ...@@ -224,6 +224,26 @@ char* strntolower(char *dst, const char *src, int32_t n) {
return dst; return dst;
} }
char* strntolower_s(char *dst, const char *src, int32_t n) {
char *p = dst, c;
assert(dst != NULL);
if (n == 0) {
return NULL;
}
while (n-- > 0) {
c = *src;
if (c >= 'A' && c <= 'Z') {
c -= 'A' - 'a';
}
*p++ = c;
src++;
}
return dst;
}
char *paGetToken(char *string, char **token, int32_t *tokenLen) { char *paGetToken(char *string, char **token, int32_t *tokenLen) {
char quote = 0; char quote = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册