/ Check-in [8c7e18c3]
Login

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 | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8c7e18c3f2f0487c6125f2d12720669e4d40e760
User & Date: drh 2006-01-23 15:39:59
Context
2006-01-23
15:54
Cut over the patches to support WinCE. Ticket #1600. (CVS 3003) check-in: 436287c2 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: 8c7e18c3 user: drh tags: trunk
15:25
Further coverage improvements for pager.c and another IO error bug fix. (CVS 3001) check-in: a9ec5ee4 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.252 2006/01/23 15:25:48 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.253 2006/01/23 15:39:59 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include "os.h"
    26     26   #include "pager.h"
    27     27   #include <assert.h>
    28     28   #include <string.h>
................................................................................
  2690   2690         TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno);
  2691   2691         CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3);
  2692   2692         if( rc!=SQLITE_OK ){
  2693   2693           i64 fileSize;
  2694   2694           int rc2 = sqlite3OsFileSize(pPager->fd, &fileSize);
  2695   2695           if( rc2!=SQLITE_OK || fileSize>=pgno*pPager->pageSize ){
  2696   2696   	  /* An IO error occured in one of the the sqlite3OsSeek() or
  2697         -          ** sqlite3OsRead() calls above. Unreference the page and then
  2698         -          ** set it's page number to 0 (0 means "not a page").
  2699         -          */
         2697  +          ** sqlite3OsRead() calls above. */
  2700   2698             sqlite3pager_unref(PGHDR_TO_DATA(pPg));
  2701         -          pPg->pgno = 0;
  2702   2699             return rc;
  2703   2700           }else{
  2704   2701             clear_simulated_io_error();
  2705   2702             memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
  2706   2703           }
  2707   2704         }else{
  2708   2705           TEST_INCR(pPager->nRead);

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.181 2006/01/23 13:00:38 drh Exp $
           17  +** $Id: util.c,v 1.182 2006/01/23 15:39:59 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <stdarg.h>
    22     22   #include <ctype.h>
    23     23   
    24     24   /*
    25     25   ** MALLOC WRAPPER ARCHITECTURE
    26     26   **
    27     27   ** The sqlite code accesses dynamic memory allocation/deallocation by invoking
    28         -** the following four APIs (which may be implemented as macros).
           28  +** the following six APIs (which may be implemented as macros).
    29     29   **
    30     30   **     sqlite3Malloc()
    31     31   **     sqlite3MallocRaw()
    32     32   **     sqlite3Realloc()
    33     33   **     sqlite3ReallocOrFree()
    34     34   **     sqlite3Free()
    35     35   **     sqlite3AllocSize()
    36     36   **
    37     37   ** The function sqlite3FreeX performs the same task as sqlite3Free and is
    38     38   ** guaranteed to be a real function. The same holds for sqlite3MallocX
    39     39   **
    40         -** The above APIs are implemented in terms of the functions provided at the Os
    41         -** level (not in this file). The Os level interface is never accessed directly
           40  +** The above APIs are implemented in terms of the functions provided in the
           41  +** operating-system interface. The OS interface is never accessed directly
    42     42   ** by code outside of this file.
    43     43   **
    44     44   **     sqlite3OsMalloc()
    45     45   **     sqlite3OsRealloc()
    46     46   **     sqlite3OsFree()
    47     47   **     sqlite3OsAllocationSize()
    48     48   **
................................................................................
    51     51   ** sqlite3OsRealloc() fails (or if the soft-heap-limit for the thread is
    52     52   ** exceeded). Function sqlite3Malloc() usually invokes
    53     53   ** sqlite3MallocRaw().
    54     54   **
    55     55   ** MALLOC TEST WRAPPER ARCHITECTURE
    56     56   **
    57     57   ** The test wrapper provides extra test facilities to ensure the library 
    58         -** does not leak memory and handles the failure of the underlying (Os level)
           58  +** does not leak memory and handles the failure of the underlying OS level
    59     59   ** allocation system correctly. It is only present if the library is 
    60     60   ** compiled with the SQLITE_MEMDEBUG macro set.
    61     61   **
    62     62   **     * Guardposts to detect overwrites.
    63     63   **     * Ability to cause a specific Malloc() or Realloc() to fail.
    64     64   **     * Audit outstanding memory allocations (i.e check for leaks).
    65     65   */