/ Check-in [1edfdcbf]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a memory leak that occurs as a result of an IO error. (CVS 2224)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1edfdcbf142b380172a26d094e6e4a3900db8463
User & Date: danielk1977 2005-01-17 03:40:08
Context
2005-01-17
03:42
Add incomplete, preliminary drafts of new documentation. (CVS 2225) check-in: a01159e8 user: drh tags: trunk
03:40
Fix a memory leak that occurs as a result of an IO error. (CVS 2224) check-in: 1edfdcbf user: danielk1977 tags: trunk
02:12
Change some assert()s that could fail if the database is corrupt to return SQLITE_CORRUPT instead. (CVS 2223) check-in: 2d58c0af user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.442 2005/01/12 09:10:40 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.443 2005/01/17 03:40:08 danielk1977 Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
  1821   1821       ** record header if the record header does not fit on a single page
  1822   1822       ** in the B-Tree.  When that happens, use sqlite3VdbeMemFromBtree() to
  1823   1823       ** acquire the complete header text.
  1824   1824       */
  1825   1825       if( !zRec && avail<szHdr ){
  1826   1826         rc = sqlite3VdbeMemFromBtree(pCrsr, 0, szHdr, pC->keyAsData, &sMem);
  1827   1827         if( rc!=SQLITE_OK ){
  1828         -        goto abort_due_to_error;
         1828  +        goto op_column_out;
  1829   1829         }
  1830   1830         zData = sMem.z;
  1831   1831       }
  1832   1832   
  1833   1833       /* Scan the header and use it to fill in the aType[] and aOffset[]
  1834   1834       ** arrays.  aType[i] will contain the type integer for the i-th
  1835   1835       ** column and aOffset[i] will contain the offset from the beginning
................................................................................
  1847   1847       sMem.flags = MEM_Null;
  1848   1848   
  1849   1849       /* The header should end at the start of data and the data should
  1850   1850       ** end at last byte of the record. If this is not the case then
  1851   1851       ** we are dealing with a malformed record.
  1852   1852       */
  1853   1853       if( idx!=szHdr || offset!=payloadSize ){
  1854         -      sqliteFree(aType);
  1855         -      if( pC ) pC->aType = 0;
  1856   1854         rc = SQLITE_CORRUPT;
  1857         -      break;
         1855  +      goto op_column_out;
  1858   1856       }
  1859   1857   
  1860   1858       /* Remember all aType and aColumn information if we have a cursor
  1861   1859       ** to remember it in. */
  1862   1860       if( pC ){
  1863   1861         pC->payloadSize = payloadSize;
  1864   1862         pC->aType = aType;
................................................................................
  1872   1870     assert( rc==SQLITE_OK );
  1873   1871     if( zRec ){
  1874   1872       zData = &zRec[aOffset[p2]];
  1875   1873     }else{
  1876   1874       len = sqlite3VdbeSerialTypeLen(aType[p2]);
  1877   1875       rc = sqlite3VdbeMemFromBtree(pCrsr, aOffset[p2], len, pC->keyAsData, &sMem);
  1878   1876       if( rc!=SQLITE_OK ){
  1879         -      goto abort_due_to_error;
         1877  +      goto op_column_out;
  1880   1878       }
  1881   1879       zData = sMem.z;
  1882   1880     }
  1883   1881     sqlite3VdbeSerialGet(zData, aType[p2], pTos);
  1884   1882     pTos->enc = db->enc;
  1885   1883   
  1886   1884     /* If we dynamically allocated space to hold the data (in the
................................................................................
  1897   1895       pTos->flags |= MEM_Dyn|MEM_Term;
  1898   1896     }
  1899   1897   
  1900   1898     /* pTos->z might be pointing to sMem.zShort[].  Fix that so that we
  1901   1899     ** can abandon sMem */
  1902   1900     rc = sqlite3VdbeMemMakeWriteable(pTos);
  1903   1901   
         1902  +op_column_out:
  1904   1903     /* Release the aType[] memory if we are not dealing with cursor */
  1905         -  if( !pC ){
         1904  +  if( !pC || !pC->aType ){
  1906   1905       sqliteFree(aType);
  1907   1906     }
  1908   1907     break;
  1909   1908   }
  1910   1909   
  1911   1910   /* Opcode: MakeRecord P1 P2 P3
  1912   1911   **