diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 01a4ed32f11e2badd6bda7ffdf862195c408dcbd..aee60da20147c674979540aa73da5ac101fae7f0 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -194,9 +194,9 @@ static FORCE_INLINE bool isNull(const char *val, int32_t type) { case TSDB_DATA_TYPE_DOUBLE: return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL; case TSDB_DATA_TYPE_NCHAR: - return *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; + return varDataLen(val) == sizeof(int32_t) && *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; case TSDB_DATA_TYPE_BINARY: - return *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; + return varDataLen(val) == sizeof(int8_t) && *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; default: return false; }; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index f0a2694b608363518c76b63d2e1e674330fba2fa..8ca71e4555534b874fd173edaf25896d9613decf 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -2284,7 +2284,7 @@ void filterPrepare(void* expr, void* param) { if (pInfo->optr == TSDB_RELATION_IN) { pInfo->q = (char*) pCond->arr; } else { - pInfo->q = calloc(1, pSchema->bytes); + pInfo->q = calloc(1, pSchema->bytes + TSDB_NCHAR_SIZE); // to make sure tonchar does not cause invalid write, since the '\0' needs at least sizeof(wchar_t) space. tVariantDump(pCond, pInfo->q, pSchema->type, true); } }