From 46d044d81071a4779c09678eb9b7d2cf7aa9844c Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Tue, 12 Jun 2012 18:13:09 +0000 Subject: [PATCH] Upstream commit in trunk: http://www.sqlite.org/src/info/f9c4a7c8f4 Upstream commits in branch-3.7.6: http://www.sqlite.org/src/info/a61786e760 (third hunk) http://www.sqlite.org/src/info/e6a04bf9f1 (correction) I have left out the comment addition seen in the trunk commit, because the backport to the 3.7.6 branch doesn't include it. [Patch from Evangelos Foutras ] BUG=122525 TEST=distros using gcc4.7 shouldn't crash. see bug. R=shess@chromium.org Review URL: https://chromiumcodereview.appspot.com/10387026 Patch from Evangelos Foutras . git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141687 0039d316-1c4b-4281-b951-d872f2087c98 --- AUTHORS | 1 + third_party/sqlite/README.chromium | 2 ++ third_party/sqlite/amalgamation/sqlite3.c | 4 +-- ....3-fix-out-of-scope-memory-reference.patch | 26 +++++++++++++++++++ third_party/sqlite/src/ext/fts3/fts3_write.c | 4 +-- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 third_party/sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch diff --git a/AUTHORS b/AUTHORS index ef1d452ecc3d..858b431fa5c5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -186,3 +186,4 @@ Shouqun Liu Jake Helfert Hongbo Min Anastasios Cassiotis +Evangelos Foutras diff --git a/third_party/sqlite/README.chromium b/third_party/sqlite/README.chromium index 7b102dd326ea..789971391a94 100644 --- a/third_party/sqlite/README.chromium +++ b/third_party/sqlite/README.chromium @@ -70,6 +70,7 @@ webdb.patch test.patch mac_time_machine.patch system-sqlite.patch +sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch So, e.g. you could do this to apply all our patches to vanilla SQLite: @@ -84,6 +85,7 @@ patch -p0 < ../sqlite/webdb.patch patch -p0 < ../sqlite/test.patch patch -p0 < ../sqlite/mac_time_machine.patch patch -p0 < ../sqlite/system-sqlite.patch +patch -p0 < ../sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch This will only be the case if all changes we make also update the corresponding patch files. Therefore please remember to do that whenever you make a change! diff --git a/third_party/sqlite/amalgamation/sqlite3.c b/third_party/sqlite/amalgamation/sqlite3.c index 9c66c16c9e47..780d2336aa2c 100644 --- a/third_party/sqlite/amalgamation/sqlite3.c +++ b/third_party/sqlite/amalgamation/sqlite3.c @@ -119149,13 +119149,13 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderPending( Fts3SegReader **ppReader /* OUT: SegReader for pending-terms */ ){ Fts3SegReader *pReader = 0; /* Fts3SegReader object to return */ + Fts3HashElem *pE; /* Iterator variable */ Fts3HashElem **aElem = 0; /* Array of term hash entries to scan */ int nElem = 0; /* Size of array at aElem */ int rc = SQLITE_OK; /* Return Code */ if( isPrefix ){ int nAlloc = 0; /* Size of allocated array at aElem */ - Fts3HashElem *pE = 0; /* Iterator variable */ for(pE=fts3HashFirst(&p->pendingTerms); pE; pE=fts3HashNext(pE)){ char *zKey = (char *)fts3HashKey(pE); @@ -119187,7 +119187,7 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderPending( } }else{ - Fts3HashElem *pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm); + pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm); if( pE ){ aElem = &pE; nElem = 1; diff --git a/third_party/sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch b/third_party/sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch new file mode 100644 index 000000000000..a5b031b1d3ad --- /dev/null +++ b/third_party/sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch @@ -0,0 +1,26 @@ +--- ext/fts3/fts3_write.c.orig 2012-05-08 21:05:03.000000000 +0300 ++++ ext/fts3/fts3_write.c 2012-05-08 21:07:08.000000000 +0300 +@@ -1238,13 +1238,13 @@ int sqlite3Fts3SegReaderPending( + Fts3SegReader **ppReader /* OUT: SegReader for pending-terms */ + ){ + Fts3SegReader *pReader = 0; /* Fts3SegReader object to return */ ++ Fts3HashElem *pE; /* Iterator variable */ + Fts3HashElem **aElem = 0; /* Array of term hash entries to scan */ + int nElem = 0; /* Size of array at aElem */ + int rc = SQLITE_OK; /* Return Code */ + + if( isPrefix ){ + int nAlloc = 0; /* Size of allocated array at aElem */ +- Fts3HashElem *pE = 0; /* Iterator variable */ + + for(pE=fts3HashFirst(&p->pendingTerms); pE; pE=fts3HashNext(pE)){ + char *zKey = (char *)fts3HashKey(pE); +@@ -1276,7 +1276,7 @@ int sqlite3Fts3SegReaderPending( + } + + }else{ +- Fts3HashElem *pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm); ++ pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm); + if( pE ){ + aElem = &pE; + nElem = 1; diff --git a/third_party/sqlite/src/ext/fts3/fts3_write.c b/third_party/sqlite/src/ext/fts3/fts3_write.c index 1e71874384aa..3636c7dfc15d 100644 --- a/third_party/sqlite/src/ext/fts3/fts3_write.c +++ b/third_party/sqlite/src/ext/fts3/fts3_write.c @@ -1238,13 +1238,13 @@ int sqlite3Fts3SegReaderPending( Fts3SegReader **ppReader /* OUT: SegReader for pending-terms */ ){ Fts3SegReader *pReader = 0; /* Fts3SegReader object to return */ + Fts3HashElem *pE; /* Iterator variable */ Fts3HashElem **aElem = 0; /* Array of term hash entries to scan */ int nElem = 0; /* Size of array at aElem */ int rc = SQLITE_OK; /* Return Code */ if( isPrefix ){ int nAlloc = 0; /* Size of allocated array at aElem */ - Fts3HashElem *pE = 0; /* Iterator variable */ for(pE=fts3HashFirst(&p->pendingTerms); pE; pE=fts3HashNext(pE)){ char *zKey = (char *)fts3HashKey(pE); @@ -1276,7 +1276,7 @@ int sqlite3Fts3SegReaderPending( } }else{ - Fts3HashElem *pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm); + pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm); if( pE ){ aElem = &pE; nElem = 1;