]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an obscure memory leak in FTS3 that can come about when two memory
authordrh <drh@noemail.net>
Fri, 8 Jun 2012 14:01:53 +0000 (14:01 +0000)
committerdrh <drh@noemail.net>
Fri, 8 Jun 2012 14:01:53 +0000 (14:01 +0000)
allocations are immediately adjacent to one another.

FossilOrigin-Name: 025227be5495f950c466dfabac140cba69e498be

ext/fts3/fts3_write.c
manifest
manifest.uuid

index 17bb87bdf16f28658f57ea3daa7369984b27ef77..bee08e19ad8388752a6a082c6d834c14a3e577a9 100644 (file)
@@ -136,7 +136,8 @@ struct Fts3DeferredToken {
 */
 struct Fts3SegReader {
   int iIdx;                       /* Index within level, or 0x7FFFFFFF for PT */
-  int bLookup;                    /* True for a lookup only */
+  u8 bLookup;                     /* True for a lookup only */
+  u8 rootOnly;                    /* True for a root-only reader */
 
   sqlite3_int64 iStartBlock;      /* Rowid of first leaf block to traverse */
   sqlite3_int64 iLeafEndBlock;    /* Rowid of final leaf block to traverse */
@@ -170,7 +171,7 @@ struct Fts3SegReader {
 };
 
 #define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)
-#define fts3SegReaderIsRootOnly(p) ((p)->aNode==(char *)&(p)[1])
+#define fts3SegReaderIsRootOnly(p) ((p)->rootOnly!=0)
 
 /*
 ** An instance of this structure is used to create a segment b-tree in the
@@ -1581,7 +1582,7 @@ int sqlite3Fts3SegReaderNew(
   }
   memset(pReader, 0, sizeof(Fts3SegReader));
   pReader->iIdx = iAge;
-  pReader->bLookup = bLookup;
+  pReader->bLookup = bLookup!=0;
   pReader->iStartBlock = iStartLeaf;
   pReader->iLeafEndBlock = iEndLeaf;
   pReader->iEndBlock = iEndBlock;
@@ -1589,6 +1590,7 @@ int sqlite3Fts3SegReaderNew(
   if( nExtra ){
     /* The entire segment is stored in the root node. */
     pReader->aNode = (char *)&pReader[1];
+    pReader->rootOnly = 1;
     pReader->nNode = nRoot;
     memcpy(pReader->aNode, zRoot, nRoot);
     memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);
index fa00549acad2f1c79e64e31c3c505411a4fd31f5..5876291154b24e8905712ccdb8fcc6cbc87340df 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\sin\svtab1.test\scausing\sit\sto\sfail\swhen\srun\swith\sany\spermutation\sthat\sexecutes\sSQL\swithin\sthe\stcl\s"sqlite3"\scommand.
-D 2012-06-08T11:48:40.417
+C Fix\san\sobscure\smemory\sleak\sin\sFTS3\sthat\scan\scome\sabout\swhen\stwo\smemory\nallocations\sare\simmediately\sadjacent\sto\sone\sanother.
+D 2012-06-08T14:01:53.027
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -72,7 +72,7 @@ F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68
 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
 F ext/fts3/fts3_unicode.c 49e36e6ba59f79e6bd6a8bfe434570fe48d20559
 F ext/fts3/fts3_unicode2.c 2965d217c37079f1dbbdbd2c58f843be285d73f2
-F ext/fts3/fts3_write.c 6a6391d6b01114f885e24e1f66bbc11ffba0e9e2
+F ext/fts3/fts3_write.c 794438f904cdf4516b258e530c0065efadb7b9b5
 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
 F ext/fts3/tool/fts3view.c 6cfc5b67a5f0e09c0d698f9fd012c784bfaa9197
@@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P cfcbf9375fddd0aae0dd17bdc76a710ab77ef667
-R 8ff78017c6658336dad044270ecb0a43
-U dan
-Z 28491c4fd8a5cdbccb56a6e17a0bf165
+P 006db555260273209933371d17afb33d557baa68
+R a3c1e8a9e6eec9c51478c97a48291850
+U drh
+Z d9212c98f4fefc48d255111660b350de
index d4dd001a07328bf313299b890767bfe84422afc3..bec602a3e6dcf850c45c9ee1eaa07aa7667718de 100644 (file)
@@ -1 +1 @@
-006db555260273209933371d17afb33d557baa68
\ No newline at end of file
+025227be5495f950c466dfabac140cba69e498be
\ No newline at end of file