🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #675

Re: Out-of-bounds pointers

#675
From: Alan J Rosenthal
Date: Sat, 07 Oct 1989 17:14
25 lines
1382 bytes
scott@bbxsda.UUCP (Scott Amspoker) writes:
>What was once bad coding style now was considered a bug.  Take the following
>code fragment as an example:
>
>my_proc()
>   {
>   register char *p;
>
>   p = (char*)malloc(1000);
>   free(p);  /* free never returns but core dumps instead - why? */
>   }

No, no, no.  It was never said that this code fragment wasn't conforming.  It
is, other than the missing declaration of malloc() which I assume you assumed
was present previously in the file.  free() has to work correctly.  The user
cannot dereference invalid pointers, but the compiler can if it knows that it
is safe to do so, and must not dereference invalid pointers if it doesn't know
whether or not it is safe.

And this fragment was never considered bad coding style, again apart from the
fact that you are mallocing memory and not doing anything with it.  You seem to
be claiming that use of free() is now non-portable and was always considered
bad coding style.

ajr
Technical Details
Message-ID: <1989Oct7.131404.656@jarvis.csri.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
References: <1009@mtxinu.UUCP> <12570028@hpclwjm.HP.COM> <868@crdos1.crd.ge.COM> <217@bbxsda.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
From: flaps@dgp.toronto.edu (Alan J Rosenthal)
Newsgroups: comp.std.c
Subject: Re: Out-of-bounds pointers
Message-ID: <1989Oct7.131404.656@jarvis.csri.toronto.edu>
Date: 7 Oct 89 17:14:05 GMT
References: <1009@mtxinu.UUCP> <12570028@hpclwjm.HP.COM> <868@crdos1.crd.ge.COM> <217@bbxsda.UUCP>
Lines: 25