/ Check-in [17cb5e95]
Login

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

Overview
Comment:Fix a bug in hash.c introduced by [305b66672653].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 17cb5e951e419b1221ae4595d20059d90a361a39
User & Date: dan 2012-08-07 15:19:27
Context
2012-08-07
17:41
Add extra tests for secure-delete mode. check-in: e380cd3c user: dan tags: trunk
15:19
Fix a bug in hash.c introduced by [305b66672653]. check-in: 17cb5e95 user: dan tags: trunk
14:18
Do not run test script spellfix.test if SQLITE_OMIT_VIRTUAL_TABLE is defined. Fix walro.test so that it works if DEFAULT_AUTOVACUUM is defined. check-in: 26428b45 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/hash.c.

   109    109       new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);
   110    110     }
   111    111     if( new_size==pH->htsize ) return 0;
   112    112   #endif
   113    113   
   114    114     /* The inability to allocates space for a larger hash table is
   115    115     ** a performance hit but it is not a fatal error.  So mark the
   116         -  ** allocation as a benign.
          116  +  ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of 
          117  +  ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero()
          118  +  ** only zeroes the requested number of bytes whereas this module will
          119  +  ** use the actual amount of space allocated for the hash table (which
          120  +  ** may be larger than the requested amount).
   117    121     */
   118    122     sqlite3BeginBenignMalloc();
   119         -  new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) );
          123  +  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );
   120    124     sqlite3EndBenignMalloc();
   121    125   
   122    126     if( new_ht==0 ) return 0;
   123    127     sqlite3_free(pH->ht);
   124    128     pH->ht = new_ht;
   125    129     pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);
          130  +  memset(new_ht, 0, new_size*sizeof(struct _ht));
   126    131     for(elem=pH->first, pH->first=0; elem; elem = next_elem){
   127    132       unsigned int h = strHash(elem->pKey, elem->nKey) % new_size;
   128    133       next_elem = elem->next;
   129    134       insertElement(pH, &new_ht[h], elem);
   130    135     }
   131    136     return 1;
   132    137   }