aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog4
-rw-r--r--util/memory.c6
2 files changed, 10 insertions, 0 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index edc261806..aad8eb107 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,7 @@
+2002-05-02 Werner Koch <[email protected]>
+
+ * memory.c (alloc): Malloc at least 1 byte. Noted by Winona Brown.
+
2002-04-23 David Shaw <[email protected]>
* miscutil.c: New function answer_is_yes_no_default() to give a
diff --git a/util/memory.c b/util/memory.c
index fef2acc82..fb099f852 100644
--- a/util/memory.c
+++ b/util/memory.c
@@ -415,6 +415,8 @@ FNAME(alloc)( size_t n FNAMEPRT )
char *p;
#ifdef M_GUARD
+ if(!n)
+ out_of_core(n,0); /* should never happen */
if( !(p = malloc( n + EXTRA_ALIGN+5 )) )
out_of_core(n,0);
store_len(p,n,0);
@@ -422,6 +424,10 @@ FNAME(alloc)( size_t n FNAMEPRT )
p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
return p+EXTRA_ALIGN+4;
#else
+ /* mallocing zero bytes is undefined by ISO-C, so we better make
+ sure that it won't happen */
+ if (!n)
+ n = 1;
if( !(p = malloc( n )) )
out_of_core(n,0);
return p;