Subj : Re: Codeguard found error in sprintf() To : borland.public.cpp.borlandcpp From : "MarvinAvery" Date : Wed Feb 25 2004 09:26 am "Richard Hufford" wrote in message news:403bf772@newsgroups.borland.com... > I've just started using Codeguard to look for errors in my BC++ 5.01 > program, and it found an error in one of my common uses of sprintf(). My > code looks much like this: > > char buf[100]; > char *r = new char[8]; > strcpy (r, "richard"); > sprintf (buf, "%25s", r); > > Codeguard gives this message: > CodeGuard Error: Access overrun (thread 0x0114) > Attempt to access 25 byte(s) at 0x014C63B4, that is at heap block 0x014C63B4 > which is only 8 bytes long. > I get a similar problem with sscanf(): char sLine[256]; sscanf (sLine, "%*10s%d", &i); Note that my code works perfectly. It's just that CodeGuard complains about this line. However, I use sscanf() elsewhere with no CodeGuard complaints. -- Marvin Avery marvin.avery@hrdc-drhc.gc.ca .