Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.lang.c Subject: Re: realloc() (was: Re: Safe coding practices) Message-ID: <1991Jan30.193308.3897@athena.mit.edu> Date: 30 Jan 91 19:33:08 GMT References: <23975:Jan2516:36:5891@kramden.acf.nyu.edu> <1991Jan30.121425.16882@unhd.unh.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 16 In article <1991Jan30.121425.16882@unhd.unh.edu>, pas@unhd.unh.edu (Paul A. Sand) writes: |> Emphasis is Jaeschke's. Even a tyro like me can recognize that you |> are in big trouble if (a) the realloc() fails, (b) ptr is your only |> access to the block, and (c) you had something important there. I believe that if the realloc() fails, the memory block pointed to by the pointer passed into realloc() is no longer guaranteed to be valid. Therefore, Jaeschke is right -- after realloc() returns NULL, you should not try to use the block whose address you passed into realloc(). -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710