delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/02/18:21:45

Date: Mon, 2 Jul 2001 18:19:36 -0400
Message-Id: <200107022219.SAA04299@envy.delorie.com>
X-Authentication-Warning: envy.delorie.com: dj set sender to dj AT envy DOT delorie DOT com using -f
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
CC: sokal AT holyrood DOT ed DOT ac DOT uk
In-reply-to: <Pine.SOL.4.33.0107022250120.27631-100000@holyrood.ed.ac.uk>
(message from Daniel Barker on Mon, 2 Jul 2001 22:55:15 +0100)
Subject: Re: malloc() problem, DJDEV 203
References: <Pine DOT SOL DOT 4 DOT 33 DOT 0107022250120 DOT 27631-100000 AT holyrood DOT ed DOT ac DOT uk>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> I noticed this whilst checking a test I have written for my own
> malloc() wrapper function.  malloc() does not indicate failure for a
> very large allocation.

Try -8 instead of -1, although size_t is unsigned, so you really
should use 4294967288U, not -8.  Your request is (humorously) getting
rounded up (to a 8-byte boundary) from 4294967295U (-1) to 4294967296U
(0), and 0 is a valid request to malloc.

It would be trivial to add a check for values 4294967289U through
4294967295U in djgpp's src/libc/ansi/stdlib/malloc.c if someone wants
to use this as an excuse to get into djgpp development ;-)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019