Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a bug in pager.c that was overwriting freed memory. Comment changes in util.c. (CVS 3002) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8c7e18c3f2f0487c6125f2d12720669e |
User & Date: | drh 2006-01-23 15:39:59.000 |
Context
2006-01-23
| ||
15:54 | Cut over the patches to support WinCE. Ticket #1600. (CVS 3003) (check-in: 436287c2bf user: drh tags: trunk) | |
15:39 | Fix a bug in pager.c that was overwriting freed memory. Comment changes in util.c. (CVS 3002) (check-in: 8c7e18c3f2 user: drh tags: trunk) | |
15:25 | Further coverage improvements for pager.c and another IO error bug fix. (CVS 3001) (check-in: a9ec5ee472 user: danielk1977 tags: trunk) | |
Changes
Changes to src/pager.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.253 2006/01/23 15:39:59 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include "os.h" #include "pager.h" #include <assert.h> #include <string.h> |
︙ | ︙ | |||
2690 2691 2692 2693 2694 2695 2696 | TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno); CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); if( rc!=SQLITE_OK ){ i64 fileSize; int rc2 = sqlite3OsFileSize(pPager->fd, &fileSize); if( rc2!=SQLITE_OK || fileSize>=pgno*pPager->pageSize ){ /* An IO error occured in one of the the sqlite3OsSeek() or | | < < < | 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 | TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno); CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); if( rc!=SQLITE_OK ){ i64 fileSize; int rc2 = sqlite3OsFileSize(pPager->fd, &fileSize); if( rc2!=SQLITE_OK || fileSize>=pgno*pPager->pageSize ){ /* An IO error occured in one of the the sqlite3OsSeek() or ** sqlite3OsRead() calls above. */ sqlite3pager_unref(PGHDR_TO_DATA(pPg)); return rc; }else{ clear_simulated_io_error(); memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize); } }else{ TEST_INCR(pPager->nRead); |
︙ | ︙ |
Changes to src/util.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** | | | | | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** ** $Id: util.c,v 1.182 2006/01/23 15:39:59 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <stdarg.h> #include <ctype.h> /* ** MALLOC WRAPPER ARCHITECTURE ** ** The sqlite code accesses dynamic memory allocation/deallocation by invoking ** the following six APIs (which may be implemented as macros). ** ** sqlite3Malloc() ** sqlite3MallocRaw() ** sqlite3Realloc() ** sqlite3ReallocOrFree() ** sqlite3Free() ** sqlite3AllocSize() ** ** The function sqlite3FreeX performs the same task as sqlite3Free and is ** guaranteed to be a real function. The same holds for sqlite3MallocX ** ** The above APIs are implemented in terms of the functions provided in the ** operating-system interface. The OS interface is never accessed directly ** by code outside of this file. ** ** sqlite3OsMalloc() ** sqlite3OsRealloc() ** sqlite3OsFree() ** sqlite3OsAllocationSize() ** ** Functions sqlite3MallocRaw() and sqlite3Realloc() may invoke ** sqlite3_release_memory() if a call to sqlite3OsMalloc() or ** sqlite3OsRealloc() fails (or if the soft-heap-limit for the thread is ** exceeded). Function sqlite3Malloc() usually invokes ** sqlite3MallocRaw(). ** ** MALLOC TEST WRAPPER ARCHITECTURE ** ** The test wrapper provides extra test facilities to ensure the library ** does not leak memory and handles the failure of the underlying OS level ** allocation system correctly. It is only present if the library is ** compiled with the SQLITE_MEMDEBUG macro set. ** ** * Guardposts to detect overwrites. ** * Ability to cause a specific Malloc() or Realloc() to fail. ** * Audit outstanding memory allocations (i.e check for leaks). */ |
︙ | ︙ |