SQLite

Check-in [b99d19d651]
Login

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

Overview
Comment:Do not incorrectly report a malloc() failure when allocating 0 bytes. Fixes a problem in bind.test. (CVS 4931)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b99d19d651b00dcc7bdb36facfd9ecffe4fafd9f
User & Date: danielk1977 2008-03-28 19:15:35.000
Context
2008-03-28
19:16
Fix a memory leak that can occur when the library API is misused. (CVS 4932) (check-in: 2b6d3e015e user: danielk1977 tags: trunk)
19:15
Do not incorrectly report a malloc() failure when allocating 0 bytes. Fixes a problem in bind.test. (CVS 4931) (check-in: b99d19d651 user: danielk1977 tags: trunk)
18:11
Fix for #3022. Handle queries like "SELECT min(b) FROM T WHERE a = X AND b > X" when there is an index on (a,b). (CVS 4930) (check-in: bce2897535 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbemem.c.
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  assert( 1 >=
    ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) +
    (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + 
    ((pMem->flags&MEM_Ephem) ? 1 : 0) + 
    ((pMem->flags&MEM_Static) ? 1 : 0)
  );

  if( sqlite3MallocSize(pMem->zMalloc)<n ){
    n = (n>32?n:32);
    if( preserve && pMem->z==pMem->zMalloc ){
      pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
      preserve = 0;
    }else{
      sqlite3_free(pMem->zMalloc);
      pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);







|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  assert( 1 >=
    ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) +
    (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + 
    ((pMem->flags&MEM_Ephem) ? 1 : 0) + 
    ((pMem->flags&MEM_Static) ? 1 : 0)
  );

  if( !pMem->zMalloc || sqlite3MallocSize(pMem->zMalloc)<n ){
    n = (n>32?n:32);
    if( preserve && pMem->z==pMem->zMalloc ){
      pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
      preserve = 0;
    }else{
      sqlite3_free(pMem->zMalloc);
      pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);