delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/12/09:32:55

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <3C17652A.C898D48F@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gcc bug or am I blind?
References: <3C17418A DOT 85364005 AT ma DOT tum DOT de> <3C174718 DOT EF323B32 AT ma DOT tum DOT de> <3c175119 AT news DOT starhub DOT net DOT sg>
Lines: 25
Date: Wed, 12 Dec 2001 14:27:23 GMT
NNTP-Posting-Host: 12.90.177.193
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1008167243 12.90.177.193 (Wed, 12 Dec 2001 14:27:23 GMT)
NNTP-Posting-Date: Wed, 12 Dec 2001 14:27:23 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Rob Kramer wrote:
> 
> Waldemar Schultz wrote:
> 
> > of course:   dest=realloc(dest,(1+strlen(arg))*sizeof(*dest));
> > but the problem persists.
> 
> How about:
> dest = realloc (dest, (strlen (dest) + strlen (arg) + 1) * sizeof (char));
  ^^^^            ^^^^
automatically creates a memory leak on any realloc failure.  You
want:

  if (NULL == (temp = realloc(dest, /* whatever */))) {
     /* failure recovery */
  }
  else dest = temp;

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   (Remove "XXXX" from reply address. yahoo works unmodified)
   mailto:uce AT ftc DOT gov  (for spambots to harvest)


- Raw text -


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