Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Unitialized Memory Read In sscanf()

Reply
Thread Tools

Re: Unitialized Memory Read In sscanf()

 
 
Darrell Grainger
Guest
Posts: n/a
 
      06-24-2003
On 23 Jun 2003, Keith wrote:

> When running purify on the following program:
>
> #include <stdio.h>


#include <string.h>

>
> int main() {
>
> int my_int ;
> char buf[3] ;
>
> strcpy(buf, "12" ) ;
> sscanf( buf, "%d", &my_int ) ;


return 0;

> }
>
> I get a UMR on the sscanf() when using purify. This is on an IRIX machine.
>
> Any suggestions?


Other than those two items I don't see anything else wrong.

--
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdbjlgdv.lksrqek.n";char *strchr(const char *,int);while(
*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}

 
Reply With Quote
 
 
 
 
Alan Balmer
Guest
Posts: n/a
 
      06-24-2003
On Tue, 24 Jun 2003 11:47:08 -0700, Alan Balmer <(E-Mail Removed)>
wrote:

>On 24 Jun 2003 17:48:40 GMT, http://www.velocityreviews.com/forums/(E-Mail Removed) (Darrell Grainger)
>wrote:
>
>>On 23 Jun 2003, Keith wrote:
>>
>>> When running purify on the following program:
>>>
>>> #include <stdio.h>

>>
>>#include <string.h>
>>
>>>
>>> int main() {
>>>
>>> int my_int ;
>>> char buf[3] ;
>>>
>>> strcpy(buf, "12" ) ;
>>> sscanf( buf, "%d", &my_int ) ;

>>
>> return 0;
>>
>>> }
>>>
>>> I get a UMR on the sscanf() when using purify. This is on an IRIX machine.
>>>
>>> Any suggestions?

>>
>>Other than those two items I don't see anything else wrong.

>
>Hmm.... Maybe because the second parameter defaults to int and buf is
>only three chars?
>
>If so, the #include <string.h> should clear the warning.


Never mind - can't count, can't see straight, and haven't had my full
quota of coffee. Still feels like something to do with no prototype,
though.

--
Al Balmer
Balmer Consulting
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruport::DataSet unitialized constant? Michael Linfield Ruby 1 08-15-2007 10:41 PM
Detection of unitialized member variables toddel@gmail.com C++ 2 10-24-2005 07:14 PM
using % operator to print possibly unitialized data attributes Adam Monsen Python 3 09-09-2005 10:40 PM
Unitialized pointers? Greg C Programming 5 10-11-2004 01:20 AM
Re: Unitialized Memory Read In sscanf() Eric Sosman C Programming 0 06-24-2003 08:03 PM



Advertisments