SQLite

Check-in [78cb8a9a17]
Login

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

Overview
Comment:Check for zero-byte allocations in sqlite3MallocRaw. (CVS 2533)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 78cb8a9a17a29bb8d9ffb6298b25cc43f9cbfed9
User & Date: drh 2005-06-29 17:24:24.000
Context
2005-06-30
17:04
Allow the DEFAULT value of a column to be obtained by calling a function that has constant arguments, such as julianday('now'). (CVS 2534) (check-in: d273766ef2 user: drh tags: trunk)
2005-06-29
17:24
Check for zero-byte allocations in sqlite3MallocRaw. (CVS 2533) (check-in: 78cb8a9a17 user: drh tags: trunk)
15:33
Make sqlite3Malloc always return NULL when the number of bytes to allocate is 0. (CVS 2532) (check-in: 657d74ebc1 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/util.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.139 2005/06/29 15:33:00 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

#if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
#include <execinfo.h>







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.140 2005/06/29 17:24:24 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

#if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
#include <execinfo.h>
279
280
281
282
283
284
285

286
287
288
289
290
291
292

/*
** Allocate new memory but do not set it to zero.  Return NULL if
** no memory is available.  See also sqliteMalloc().
*/
void *sqlite3MallocRaw(int n){
  void *p;

  if( (p = malloc(n))==0 ){
    if( n>0 ) sqlite3_malloc_failed++;
  }
  return p;
}

/*







>







279
280
281
282
283
284
285
286
287
288
289
290
291
292
293

/*
** Allocate new memory but do not set it to zero.  Return NULL if
** no memory is available.  See also sqliteMalloc().
*/
void *sqlite3MallocRaw(int n){
  void *p;
  if( n==0 ) return 0;
  if( (p = malloc(n))==0 ){
    if( n>0 ) sqlite3_malloc_failed++;
  }
  return p;
}

/*