aboutsummaryrefslogtreecommitdiff
path: root/src/sqliteInt.h
diff options
context:
space:
mode:
authordrh <>2023-07-13 14:49:39 +0000
committerdrh <>2023-07-13 14:49:39 +0000
commitbc6d949aa3640f0e7f0ff750486f500e02aded76 (patch)
treec05f8b98db62d904c2640eb38009eab26991c9ef /src/sqliteInt.h
parent81602595a0eb65272e83f98a2a4e581bed757996 (diff)
downloadsqlite-bc6d949aa3640f0e7f0ff750486f500e02aded76.tar.gz
sqlite-bc6d949aa3640f0e7f0ff750486f500e02aded76.zip
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
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r--src/sqliteInt.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 770aa7071..f214862f7 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -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,