Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Mar 1997 00:50:01 -0800 (PST)
From:      Poul-Henning Kamp <phk@critter.dk.tfs.com>
To:        freebsd-bugs
Subject:   Re: kern/2964: malloc() returns non-null when it should not 
Message-ID:  <199703130850.AAA14778@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/2964; it has been noted by GNATS.

From: Poul-Henning Kamp <phk@critter.dk.tfs.com>
To: jmaslak@blackfire.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/2964: malloc() returns non-null when it should not 
Date: Thu, 13 Mar 1997 09:52:01 +0100

 Try this patch: 
 
 Index: malloc.c
 ===================================================================
 RCS file: /home/ncvs/src/lib/libc/stdlib/malloc.c,v
 retrieving revision 1.18.2.1
 diff -u -r1.18.2.1 malloc.c
 --- malloc.c	1996/12/30 01:35:15	1.18.2.1
 +++ malloc.c	1997/03/13 08:47:01
 @@ -731,7 +731,9 @@
      if (suicide)
  	abort();
  
 -    if (size <= malloc_maxsize)
 +    if ((size + malloc_pagesize) < size)	/* Check for overflow */
 +	result = 0;
 +    else if (size <= malloc_maxsize)
  	result =  malloc_bytes(size);
      else
  	result =  malloc_pages(size);
 
 --
 Poul-Henning Kamp           | phk@FreeBSD.ORG       FreeBSD Core-team.
 http://www.freebsd.org/~phk | phk@login.dknet.dk    Private mailbox.
 whois: [PHK]                | phk@tfs.com           TRW Financial Systems, Inc.
 Power and ignorance is a disgusting cocktail.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703130850.AAA14778>