Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ogicse!unmvax!bbx!bbxsda!scott From: scott@bbxsda.UUCP (Scott Amspoker) Newsgroups: comp.lang.c Subject: Re: realloc() (was: Re: Safe coding practices) Message-ID: <1710@bbxsda.UUCP> Date: 10 Feb 91 17:23:45 GMT References: <23975:Jan2516:36:5891@kramden.acf.nyu.edu> <1991Jan30.121425.16882@unhd.unh.edu> <00066@jimi.UUCP> Reply-To: scott@bbxsda.UUCP (Scott Amspoker) Organization: Basis International, Albuquerque, NM Lines: 19 In article <00066@jimi.UUCP> rob@jimi.UUCP writes: > My understanding has always been that if realloc() fails (returns NULL), >ALL access to the previously allocated block is gone. It makes no difference >whether you keep the original ptr or not. > > This has stuck in my head because of a particularly nasty bug due to >assuming that the original ptr was still valid after the failure. But I can't >seem to find an adequate reference to back up my 'understanding'. You're not imagining things. There was a time when that was true. We've also had to deal with that "feature". As for the present, someone has already posted a reference stating that realloc() must preserve the original data if it fails. -- Scott Amspoker | Basis International, Albuquerque, NM | This space available (505) 345-5232 | unmvax.cs.unm.edu!bbx!bbxsda!scott |