mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix an memory allocation error revealed by malloc3.test. (CVS 3733)
FossilOrigin-Name: 0f7fdb022ca7c94f7d264192e18b6e2bd1e8cff4
This commit is contained in:
14
manifest
14
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)
|
C Fix\san\smemory\sallocation\serror\srevealed\sby\smalloc3.test.\s(CVS\s3733)
|
||||||
D 2007-03-27T22:24:11
|
D 2007-03-28T01:59:34
|
||||||
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
|
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -86,7 +86,7 @@ F src/os_unix.c 0d91b28d57c0885fe97fb9020fd1091578066b5b
|
|||||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||||
F src/os_win.c 84c02837a6ec216a07e83a1d10d5a01c417bb489
|
F src/os_win.c 84c02837a6ec216a07e83a1d10d5a01c417bb489
|
||||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||||
F src/pager.c 444a49c2fa0a4d84d2877633865e1d5bc138ef57
|
F src/pager.c 1a881105a207af5526851fdc6bf57f020cbcbb88
|
||||||
F src/pager.h f1b17bf848b3dce5d9afb2701186d3c9a8826f8c
|
F src/pager.h f1b17bf848b3dce5d9afb2701186d3c9a8826f8c
|
||||||
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
|
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
|
||||||
F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
|
F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
|
||||||
@@ -255,7 +255,7 @@ F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
|
|||||||
F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
|
F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
|
||||||
F test/malloc.test 33020a87791e32302c0a30c2ce2816134a944a3b
|
F test/malloc.test 33020a87791e32302c0a30c2ce2816134a944a3b
|
||||||
F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
|
F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
|
||||||
F test/malloc3.test fd4186bee73c2a2638f4e2a05a684c06836f725b
|
F test/malloc3.test e965954b6f808876a63d3101fd70370320b509a7
|
||||||
F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
|
F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
|
||||||
F test/malloc5.test 7425272e263325fda7d32cb55706e52b5c09e7e0
|
F test/malloc5.test 7425272e263325fda7d32cb55706e52b5c09e7e0
|
||||||
F test/malloc6.test 025ae0b78542e0ddd000d23f79d93e9be9ba0f15
|
F test/malloc6.test 025ae0b78542e0ddd000d23f79d93e9be9ba0f15
|
||||||
@@ -442,7 +442,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P 902413e81b1ae8bee09987c798622a55ab2a1504
|
P 113aab2cdf4480683cd5e844b5a48dcc093792ff
|
||||||
R a3c3f96a41087c6c52e773240baf1bb3
|
R 427f67aee0e676f963d4498081735fb5
|
||||||
U drh
|
U drh
|
||||||
Z 265dc8f132e764318a2027b91d30531a
|
Z 29604fa5d015b7fb2a66f0f8519ab25a
|
||||||
|
@@ -1 +1 @@
|
|||||||
113aab2cdf4480683cd5e844b5a48dcc093792ff
|
0f7fdb022ca7c94f7d264192e18b6e2bd1e8cff4
|
11
src/pager.c
11
src/pager.c
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** 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
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -3060,6 +3060,9 @@ static int pager_open_journal(Pager *pPager){
|
|||||||
pPager->setMaster = 0;
|
pPager->setMaster = 0;
|
||||||
pPager->journalHdr = 0;
|
pPager->journalHdr = 0;
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
|
if( rc==SQLITE_NOMEM ){
|
||||||
|
sqlite3OsDelete(pPager->zJournal);
|
||||||
|
}
|
||||||
goto failed_to_open_journal;
|
goto failed_to_open_journal;
|
||||||
}
|
}
|
||||||
sqlite3OsSetFullSync(pPager->jfd, pPager->full_fsync);
|
sqlite3OsSetFullSync(pPager->jfd, pPager->full_fsync);
|
||||||
@@ -3092,6 +3095,7 @@ static int pager_open_journal(Pager *pPager){
|
|||||||
failed_to_open_journal:
|
failed_to_open_journal:
|
||||||
sqliteFree(pPager->aInJournal);
|
sqliteFree(pPager->aInJournal);
|
||||||
pPager->aInJournal = 0;
|
pPager->aInJournal = 0;
|
||||||
|
#if 0
|
||||||
if( rc==SQLITE_NOMEM ){
|
if( rc==SQLITE_NOMEM ){
|
||||||
/* If this was a malloc() failure, then we will not be closing the pager
|
/* 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,
|
** file. So delete any journal file we may have just created. Otherwise,
|
||||||
@@ -3100,8 +3104,11 @@ failed_to_open_journal:
|
|||||||
*/
|
*/
|
||||||
/* sqlite3OsDelete(pPager->zJournal); */
|
/* sqlite3OsDelete(pPager->zJournal); */
|
||||||
}else{
|
}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;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
# correctly. The emphasis of these tests are the _prepare(), _step() and
|
# correctly. The emphasis of these tests are the _prepare(), _step() and
|
||||||
# _finalize() calls.
|
# _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]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -527,7 +527,6 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
|
|||||||
set k2 [lindex $arglist [expr 2 * $i]]
|
set k2 [lindex $arglist [expr 2 * $i]]
|
||||||
set v2 [lindex $arglist [expr 2 * $i + 1]]
|
set v2 [lindex $arglist [expr 2 * $i + 1]]
|
||||||
set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit
|
set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit
|
||||||
# puts "STARTUP"
|
|
||||||
switch -- $k2 {
|
switch -- $k2 {
|
||||||
-sql {db eval [lindex $v2 1]}
|
-sql {db eval [lindex $v2 1]}
|
||||||
-prep {db eval $v2}
|
-prep {db eval $v2}
|
||||||
@@ -544,7 +543,6 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
|
|||||||
|
|
||||||
# Id of this iteration:
|
# Id of this iteration:
|
||||||
set iterid "(pc $pc).(iFail $iFail)"
|
set iterid "(pc $pc).(iFail $iFail)"
|
||||||
|
|
||||||
set k [lindex $arglist [expr 2 * $pc]]
|
set k [lindex $arglist [expr 2 * $pc]]
|
||||||
set v [lindex $arglist [expr 2 * $pc + 1]]
|
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
|
set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit
|
||||||
sqlite_malloc_fail $iFail
|
sqlite_malloc_fail $iFail
|
||||||
# puts "SQL $iterid [lindex $v 1]"
|
|
||||||
set rc [catch {db eval [lindex $v 1]} msg] ;# True error occurs
|
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
|
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"
|
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} {
|
for {set i $begin_pc} {$i < $pc} {incr i} {
|
||||||
set k2 [lindex $arglist [expr 2 * $i]]
|
set k2 [lindex $arglist [expr 2 * $i]]
|
||||||
set v2 [lindex $arglist [expr 2 * $i + 1]]
|
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]}
|
-sql {set catchupsql [lindex $v2 1]}
|
||||||
-prep {set catchupsql $v2}
|
-prep {set catchupsql $v2}
|
||||||
}
|
}
|
||||||
# puts "CATCHUP $iterid $i $catchupsql"
|
|
||||||
db eval $catchupsql
|
db eval $catchupsql
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -630,14 +624,12 @@ proc run_test {arglist {pcstart 0} {iFailStart 1}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-prep {
|
-prep {
|
||||||
# puts "PREP $iterid $v"
|
|
||||||
db eval $v
|
db eval $v
|
||||||
incr pc
|
incr pc
|
||||||
}
|
}
|
||||||
|
|
||||||
default { error "Unknown switch: $k" }
|
default { error "Unknown switch: $k" }
|
||||||
}
|
}
|
||||||
# if {$iFail > ($iFailStart+1)} return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,4 +644,3 @@ db close
|
|||||||
pp_check_for_leaks
|
pp_check_for_leaks
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user