From ee570fa4981a643934850ed9466e97828977bf66 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Apr 2005 12:06:05 +0000 Subject: [PATCH] Fix an array index bug in the default busy callback handler. Ticket #1198. (CVS 2447) FossilOrigin-Name: 3cc14b7606681d04eb56003a0996322e3b3bdc73 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 22 ++++++++++------------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index ad13ee4543..002979f0c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\svestigal\scode.\s\sAdd\sthe\sexperimental\ssqlite3_transfer_bindings()\nAPI.\s(CVS\s2446) -D 2005-04-22T02:38:38 +C Fix\san\sarray\sindex\sbug\sin\sthe\sdefault\sbusy\scallback\shandler.\r\nTicket\s#1198.\s(CVS\s2447) +D 2005-04-28T12:06:06 F Makefile.in 5c00d0037104de2a50ac7647a5f12769795957a3 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -42,7 +42,7 @@ F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 F src/insert.c 34c25c33f51a43644a42cc091ac967b070c6b6d5 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b -F src/main.c 336ab4bf0e398471a0607875f9b90b698b49ce92 +F src/main.c bab0ea1093176807a12da4038fc9d0e5dfdbddfc F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/os.h 0c805df3df02b98eb78a7a86756c3cbd4e190939 F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73 @@ -279,7 +279,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b -P 00e20690bb8cc6522c9c48f36f0c3336ae007827 -R 6a430a8ca8d157615203d0413b70c426 +P 88b39436f00d645cdb6333a7413c698c42227d3f +R 31ea01a451abe41dbf502c49252e43ec U drh -Z 51d7570a6b49b81dfa3ff13333279222 +Z 9e5b2b061f2f4dcf30af44a6a2dcbc04 diff --git a/manifest.uuid b/manifest.uuid index 5a0f9aa926..1e5b4baf8c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88b39436f00d645cdb6333a7413c698c42227d3f \ No newline at end of file +3cc14b7606681d04eb56003a0996322e3b3bdc73 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 42a031c699..7745755266 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.285 2005/03/29 23:34:58 danielk1977 Exp $ +** $Id: main.c,v 1.286 2005/04/28 12:06:06 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -618,17 +618,18 @@ static int sqliteDefaultBusyCallback( int count /* Number of times table has been busy */ ){ #if SQLITE_MIN_SLEEP_MS==1 - static const char delays[] = - { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 50, 100}; - static const short int totals[] = - { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228, 287}; + static const u8 delays[] = + { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; + static const u8 totals[] = + { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; # define NDELAY (sizeof(delays)/sizeof(delays[0])) ptr timeout = (ptr)Timeout; ptr delay, prior; - if( count <= NDELAY ){ - delay = delays[count-1]; - prior = totals[count-1]; + assert( count>=0 ); + if( count < NDELAY ){ + delay = delays[count]; + prior = totals[count]; }else{ delay = delays[NDELAY-1]; prior = totals[NDELAY-1] + delay*(count-NDELAY-1); @@ -1157,10 +1158,7 @@ int sqlite3_prepare16( /* ** This routine does the work of opening a database on behalf of ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" -** is UTF-8 encoded. The fourth argument, "def_enc" is one of the TEXT_* -** macros from sqliteInt.h. If we end up creating a new database file -** (not opening an existing one), the text encoding of the database -** will be set to this value. +** is UTF-8 encoded. */ static int openDatabase( const char *zFilename, /* Database filename UTF-8 encoded */