/ Check-in [2aae1964]
Login

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

Overview
Comment:Fix a long-standing memory leak in the hash table. The leak only appears following a malloc failure of a hash that copies its keys, which rarely happens and so we have not previously noticed it. (CVS 3777)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2aae1964572f4d4d1eae090a997e0bd9a82a69b2
User & Date: drh 2007-03-31 03:59:24
Context
2007-03-31
10:00
More coverage for pager.c. (CVS 3778) check-in: 665b119a user: danielk1977 tags: trunk
03:59
Fix a long-standing memory leak in the hash table. The leak only appears following a malloc failure of a hash that copies its keys, which rarely happens and so we have not previously noticed it. (CVS 3777) check-in: 2aae1964 user: drh tags: trunk
02:36
Fix a large memory leak in the btree layer that occurs following an I/O error when in shared cache mode. (CVS 3776) check-in: dce4cb84 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/hash.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This is the implementation of generic hash-tables
    13     13   ** used in SQLite.
    14     14   **
    15         -** $Id: hash.c,v 1.18 2006/02/14 10:48:39 danielk1977 Exp $
           15  +** $Id: hash.c,v 1.19 2007/03/31 03:59:24 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <assert.h>
    19     19   
    20     20   /* Turn bulk memory into a hash table object by initializing the
    21     21   ** fields of the Hash structure.
    22     22   **
................................................................................
   287    287     if( pEntry->chain==elem ){
   288    288       pEntry->chain = elem->next;
   289    289     }
   290    290     pEntry->count--;
   291    291     if( pEntry->count<=0 ){
   292    292       pEntry->chain = 0;
   293    293     }
   294         -  if( pH->copyKey && elem->pKey ){
          294  +  if( pH->copyKey ){
   295    295       pH->xFree(elem->pKey);
   296    296     }
   297    297     pH->xFree( elem );
   298    298     pH->count--;
   299    299     if( pH->count<=0 ){
   300    300       assert( pH->first==0 );
   301    301       assert( pH->count==0 );
................................................................................
   374    374     }
   375    375     new_elem->nKey = nKey;
   376    376     pH->count++;
   377    377     if( pH->htsize==0 ){
   378    378       rehash(pH,8);
   379    379       if( pH->htsize==0 ){
   380    380         pH->count = 0;
          381  +      if( pH->copyKey ){
          382  +        pH->xFree(new_elem->pKey);
          383  +      }
   381    384         pH->xFree(new_elem);
   382    385         return data;
   383    386       }
   384    387     }
   385    388     if( pH->count > pH->htsize ){
   386    389       rehash(pH,pH->htsize*2);
   387    390     }