out of memory while allocating 0 bytes
Dmitri
dmitri at users.sourceforge.net
Sun Sep 15 13:04:02 CEST 2002
On Sun, 2002-09-15 at 02:45, Werner Koch wrote:
> On Sun, 15 Sep 2002 03:13:41 +0900 (JST), Yamagata Yoriyuki said:
>
> > when m_alloc is called with the argument n = 0. Since malloc in this
> > system returns NULL for the request of 0-byte allocation, this causes
>
> This is known. The quick fix is to change it in util/memory.c:
>
> void *
> FNAME(alloc)( size_t n FNAMEPRT )
> ...
> #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);
Quite often another, smaller, workaround is used:
if( !(p = malloc( n+1 )) )
out_of_core(n,0);
Dmitri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : /pipermail/attachments/20020915/6336fb80/attachment.bin
More information about the Gnupg-devel
mailing list