1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Fix an off-by-one error in tests for cells overflowing the end pages. The

error is completely harmless for the default page cache, but might cause
problems for application-defined page caches that pack pages tightly
together.

FossilOrigin-Name: ce6793e954f291b6f5c29175baf730ce217328de1f0601b8935daac62af5f448
This commit is contained in:
drh
2023-07-13 14:49:39 +00:00
parent 81602595a0
commit bc6d949aa3
4 changed files with 35 additions and 12 deletions

View File

@@ -889,8 +889,31 @@ typedef INT16_TYPE LogEst;
** the end of buffer S. This macro returns true if P points to something
** contained within the buffer S.
*/
#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
/*
** P is one byte past the end of a large buffer. Return true if a span of bytes
** between S..E crosses the end of that buffer. In other words, return true
** if the sub-buffer S..E-1 overflows the buffer show last byte is P-1.
**
** S is the start of the span. E is one byte past the end of end of span.
**
** P
** |-----------------| FALSE
** |-------|
** S E
**
** P
** |-----------------|
** |-------| TRUE
** S E
**
** P
** |-----------------|
** |-------| FALSE
** S E
*/
#define SQLITE_OVERFLOW(P,S,E) (((uptr)(S)<(uptr)(P))&&((uptr)(E)>(uptr)(P)))
/*
** Macros to determine whether the machine is big or little endian,