From 267805885348ecb3a0b914b6dd95926877905456 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 20 Oct 2002 15:46:22 +0000 Subject: [PATCH] Make sure malloc(0) always returns NULL. Fix for ticket #171. (CVS 764) FossilOrigin-Name: 4622b7ce8f4727a6405ddf4f0af701db86da86bf --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2bba6412c9..1989b6dc4a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Speed\simprovement\sby\savoiding\sa\scall\sto\ssqliteBtreeLast()\swhen\sinserting\sa\nnew\srow\sinto\sa\stable.\s(CVS\s763) -D 2002-10-19T20:16:38 +C Make\ssure\smalloc(0)\salways\sreturns\sNULL.\s\sFix\sfor\sticket\s#171.\s(CVS\s764) +D 2002-10-20T15:46:23 F Makefile.in d6c9a85c2a5e696843201d090dcf8bf2f8716f2a F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -51,7 +51,7 @@ F src/threadtest.c 72bce0a284647314847bbea44616ceb056bfb77f F src/tokenize.c 62c98842447effe92eba9622bb2f9a2a8a4b97ad F src/trigger.c 5ba917fc226b96065108da28186c2efaec53e481 F src/update.c 881e4c8e7c786545da4fd2d95da19252b2e31137 -F src/util.c cd28b33c6849c9722ab72758b7b86989bc64fa27 +F src/util.c ca7650ef2cc2d50241e48029fca109a3016144ee F src/vdbe.c 4144effb953f1f25eb451dba85e69f0c34e3b788 F src/vdbe.h b7584044223104ba7896a7f87b66daebdd6022ba F src/where.c 8ff2acfcb9bb15a057512bd6207b259feed57a2c @@ -149,7 +149,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 16aad98aad4d8dd4a8400cdee32004b8c4785d60 -R 1de19ca25a16a11c2dec003aa1ffd1a2 +P d0af59fe6b9d5d026786e7cce1c49c208a0335cc +R 70da8919be02ff08191d05376cb545cc U drh -Z 58d83640e24d56cfd3739aa320366770 +Z 4581abd0f3d516911470f2cb2d447f4c diff --git a/manifest.uuid b/manifest.uuid index e0fbf054df..4b5560cd0c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0af59fe6b9d5d026786e7cce1c49c208a0335cc \ No newline at end of file +4622b7ce8f4727a6405ddf4f0af701db86da86bf \ No newline at end of file diff --git a/src/util.c b/src/util.c index 79e785bba7..a2fc36bfdf 100644 --- a/src/util.c +++ b/src/util.c @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.51 2002/09/30 01:31:22 drh Exp $ +** $Id: util.c,v 1.52 2002/10/20 15:46:23 drh Exp $ */ #include "sqliteInt.h" #include @@ -217,7 +217,9 @@ char *sqliteStrNDup_(const char *z, int n, char *zFile, int line){ ** no memory is available. */ void *sqliteMalloc(int n){ - void *p = malloc(n); + void *p; + if( n==0 ) return 0; + p = malloc(n); if( p==0 ){ sqlite_malloc_failed++; return 0; -- 2.47.3