SQLite

Check-in [7e9b886dab]
Login

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

Overview
Comment:Fix a memory leak in the sqlite3_realloc() implementation of the non-debugging memory allocator. (CVS 4475)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7e9b886dabf10557bc1aa80caad411809ce5a39f
User & Date: drh 2007-10-06 01:40:35.000
Context
2007-10-08
12:21
In windows, always open files using FILE_FLAG_RANDOM_ACCESS. Ticket #2699. (CVS 4476) (check-in: 5cdbc0972f user: drh tags: trunk)
2007-10-06
01:40
Fix a memory leak in the sqlite3_realloc() implementation of the non-debugging memory allocator. (CVS 4475) (check-in: 7e9b886dab user: drh tags: trunk)
2007-10-05
16:23
Remove #include <math.h> from all source files. It is no longer needed but causes compile problems when -DSQLITE_OMIT_FLOATING_POINT is defined. Ticket #2696. (CVS 4474) (check-in: 4424357d17 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/mem1.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite.  
**
** $Id: mem1.c,v 1.10 2007/09/02 17:50:35 drh Exp $
*/

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
*/







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite.  
**
** $Id: mem1.c,v 1.11 2007/10/06 01:40:35 drh Exp $
*/

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
*/
208
209
210
211
212
213
214


215
216
217
218
219
220
221
  sqlite3_mutex_enter(mem.mutex);
  if( mem.nowUsed+nBytes-nOld>=mem.alarmThreshold ){
    sqlite3MemsysAlarm(nBytes-nOld);
  }
  p = realloc(p, nBytes+8);
  if( p==0 ){
    sqlite3MemsysAlarm(nBytes);


    p = realloc(p, nBytes+8);
  }
  if( p ){
    p[0] = nBytes;
    p++;
    mem.nowUsed += nBytes-nOld;
    if( mem.nowUsed>mem.mxUsed ){







>
>







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
  sqlite3_mutex_enter(mem.mutex);
  if( mem.nowUsed+nBytes-nOld>=mem.alarmThreshold ){
    sqlite3MemsysAlarm(nBytes-nOld);
  }
  p = realloc(p, nBytes+8);
  if( p==0 ){
    sqlite3MemsysAlarm(nBytes);
    p = pPrior;
    p--;
    p = realloc(p, nBytes+8);
  }
  if( p ){
    p[0] = nBytes;
    p++;
    mem.nowUsed += nBytes-nOld;
    if( mem.nowUsed>mem.mxUsed ){