diff --git a/src/tsdb/inc/tsdbFile.h b/src/tsdb/inc/tsdbFile.h index 75e95631513e354960df5119b25ac3b6620a29d8..8436786157364ee3c4df717dfcb9f4b49c5a4561 100644 --- a/src/tsdb/inc/tsdbFile.h +++ b/src/tsdb/inc/tsdbFile.h @@ -257,7 +257,13 @@ static FORCE_INLINE int tsdbAppendDFile(SDFile* pDFile, void* buf, int64_t nbyte return -1; } - ASSERT(pDFile->info.size == toffset); + //bug fix. To avoid data corruption, + //the end offset of current file should be checked with file size, + //if not equal, known as file corrupted and return error. + if (pDFile->info.size != toffset) { + terrno = TSDB_CODE_TDB_FILE_CORRUPTED; + return -1; + } if (offset) { *offset = toffset;