]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an memory allocation error revealed by malloc3.test. (CVS 3733)
authordrh <drh@noemail.net>
Wed, 28 Mar 2007 01:59:33 +0000 (01:59 +0000)
committerdrh <drh@noemail.net>
Wed, 28 Mar 2007 01:59:33 +0000 (01:59 +0000)
FossilOrigin-Name: 0f7fdb022ca7c94f7d264192e18b6e2bd1e8cff4

manifest
manifest.uuid
src/pager.c
test/malloc3.test

index ee531108bb819eb2e92e396d7675b8b5969b654d..d1b1c03a2e1f2f042a40152f62bace24039b75d2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C The\sSQLITE_ENABLE_LOAD_EXTENSION\smacro\senables\sthe\sload_extension()\sSQL\nfunction\sby\sdefault\swithout\shaving\sto\sinvoke\ssqlite3_enable_load_extension()\nfirst.\s(CVS\s3732)
-D 2007-03-27T22:24:11
+C Fix\san\smemory\sallocation\serror\srevealed\sby\smalloc3.test.\s(CVS\s3733)
+D 2007-03-28T01:59:34
 F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -86,7 +86,7 @@ F src/os_unix.c 0d91b28d57c0885fe97fb9020fd1091578066b5b
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c 84c02837a6ec216a07e83a1d10d5a01c417bb489
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 444a49c2fa0a4d84d2877633865e1d5bc138ef57
+F src/pager.c 1a881105a207af5526851fdc6bf57f020cbcbb88
 F src/pager.h f1b17bf848b3dce5d9afb2701186d3c9a8826f8c
 F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
 F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
@@ -255,7 +255,7 @@ F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
 F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
 F test/malloc.test 33020a87791e32302c0a30c2ce2816134a944a3b
 F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
-F test/malloc3.test fd4186bee73c2a2638f4e2a05a684c06836f725b
+F test/malloc3.test e965954b6f808876a63d3101fd70370320b509a7
 F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
 F test/malloc5.test 7425272e263325fda7d32cb55706e52b5c09e7e0
 F test/malloc6.test 025ae0b78542e0ddd000d23f79d93e9be9ba0f15
@@ -442,7 +442,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 902413e81b1ae8bee09987c798622a55ab2a1504
-R a3c3f96a41087c6c52e773240baf1bb3
+P 113aab2cdf4480683cd5e844b5a48dcc093792ff
+R 427f67aee0e676f963d4498081735fb5
 U drh
-Z 265dc8f132e764318a2027b91d30531a
+Z 29604fa5d015b7fb2a66f0f8519ab25a
index 8df9c5a3f7ee5a5d4e366a63396a1725244ca264..08748c4903d57dfed22ab562882c2bdedcfcb6bd 100644 (file)
@@ -1 +1 @@
-113aab2cdf4480683cd5e844b5a48dcc093792ff
\ No newline at end of file
+0f7fdb022ca7c94f7d264192e18b6e2bd1e8cff4
\ No newline at end of file
index 9509cd9b727b4848983e6bd93426e9a9dd8faa06..67a2c586b8e56bd6cd84a94ee47e0da8a6b3f5d1 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.303 2007/03/27 17:37:32 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.304 2007/03/28 01:59:34 drh Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -3060,6 +3060,9 @@ static int pager_open_journal(Pager *pPager){
   pPager->setMaster = 0;
   pPager->journalHdr = 0;
   if( rc!=SQLITE_OK ){
+    if( rc==SQLITE_NOMEM ){
+      sqlite3OsDelete(pPager->zJournal);
+    }
     goto failed_to_open_journal;
   }
   sqlite3OsSetFullSync(pPager->jfd, pPager->full_fsync);
@@ -3092,6 +3095,7 @@ static int pager_open_journal(Pager *pPager){
 failed_to_open_journal:
   sqliteFree(pPager->aInJournal);
   pPager->aInJournal = 0;
+#if 0
   if( rc==SQLITE_NOMEM ){
     /* If this was a malloc() failure, then we will not be closing the pager
     ** file. So delete any journal file we may have just created. Otherwise,
@@ -3100,8 +3104,11 @@ failed_to_open_journal:
     */
     /* sqlite3OsDelete(pPager->zJournal); */
   }else{
-    pager_reset(pPager);
+    /* If we reset the pager here, we will delete pages out from under
+    ** various cursors and will ultimately segfault. */
+    /* pager_reset(pPager); */
   }
+#endif
   return rc;
 }
 
index 746e0585cc2454132c5f01aa33ae50e01400ae28..a3d4ddf8af2cabacd332854bd10b0220d6132467 100644 (file)
@@ -13,7 +13,7 @@
 # correctly. The emphasis of these tests are the _prepare(), _step() and
 # _finalize() calls.
 #
-# $Id: malloc3.test,v 1.9 2006/01/23 07:52:41 danielk1977 Exp $
+# $Id: malloc3.test,v 1.10 2007/03/28 01:59:34 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -527,7 +527,6 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
     set k2 [lindex $arglist [expr 2 * $i]]
     set v2 [lindex $arglist [expr 2 * $i + 1]]
     set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit
-# puts "STARTUP"
     switch -- $k2 {
       -sql  {db eval [lindex $v2 1]}
       -prep {db eval $v2}
@@ -544,7 +543,6 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
 
     # Id of this iteration:
     set iterid "(pc $pc).(iFail $iFail)"
-
     set k [lindex $arglist [expr 2 * $pc]]
     set v [lindex $arglist [expr 2 * $pc + 1]]
 
@@ -562,9 +560,7 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
 
         set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit
         sqlite_malloc_fail $iFail
-# puts "SQL $iterid [lindex $v 1]"
         set rc [catch {db eval [lindex $v 1]} msg]   ;# True error occurs
-# puts "rc = $rc msg = \"$msg\""
         set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit 
 
 
@@ -607,7 +603,6 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
                 error "Statement \"[lindex $v 1]\" caused a rollback"
               }
 
-# puts "Statement \"[lindex $v 1]\" caused a rollback"
               for {set i $begin_pc} {$i < $pc} {incr i} {
                 set k2 [lindex $arglist [expr 2 * $i]]
                 set v2 [lindex $arglist [expr 2 * $i + 1]]
@@ -616,7 +611,6 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
                   -sql  {set catchupsql [lindex $v2 1]}
                   -prep {set catchupsql $v2}
                 }
-# puts "CATCHUP $iterid $i $catchupsql"
                 db eval $catchupsql
               }
             }
@@ -630,14 +624,12 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
       }
 
       -prep {
-# puts "PREP $iterid $v"
         db eval $v
         incr pc
       }
 
       default { error "Unknown switch: $k" }
     }
-# if {$iFail > ($iFailStart+1)} return
   }
 }
 
@@ -652,4 +644,3 @@ db close
 pp_check_for_leaks
 
 finish_test
-