🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2627

Re: Ultimate bug

#2627
From: Dan Pop
Date: Sat, 20 Apr 1996 18:21
29 lines
1305 bytes
In <4l881k$76k@solutions.solon.com> Artyom@kansmen.com (Art Shelest) writes:

>Below is the bug I got to fix last night (in someone else's code).
>It's not the actual code, but you'll get the idea:
>
>void* AllocMem( size_t cbMem )
>{
>   void* pMem = malloc( cbMem );
>
>   if( pMem )
>      memset( &pMem, 0, cbMem );  /* note & */
>
>   return pMem;
>}
>
>I wonder if Lint would ever catch this one.

Never.  Any kind of pointer (except function pointers and pointers to const
objects) is OK as the first argument of memset, which expects a void pointer.

Reading the programmer's mind and comparing it with programmer's code is
beyond the current state of the art in lint technology.

Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID: <4lb9vp$lea@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4l881k$76k@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: danpop@mail.cern.ch (Dan Pop)
Newsgroups: comp.lang.c.moderated
Subject: Re: Ultimate bug
Date: 20 Apr 1996 13:21:45 -0500
Organization: CERN European Lab for Particle Physics
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4lb9vp$lea@solutions.solon.com>
References: <4l881k$76k@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: NN version 6.5.0 #18 (NOV)