Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: more gcc crap



>>>>> "Scott" == Scott Stone <sstone@example.com> writes:

    Scott> Ok, suppose I have a variable:
    Scott> char *s0;
    Scott> it's been malloced with
    Scott> s0=(char *)malloc(80);
    Scott> The function it's in does:

    Scott> sprintf(s0,"some_text %s some_text",some_other_string_var);
    Scott> newtWinMessage("Title","Ok",s0);

If "some_other_string_var" is more than 80 characters, your in
trouble. Take a look with gdb and see how long it is, or try a strlen
of it. Its also possible that newtWinMessage is overwriting it.

    Scott> if (s0) free(s0);

    Scott> what the heck causes something like this?  It seems like
    Scott> the if clause would prevent this sort of crap.. it's acting
    Scott> like I'm trying to free an un-malloced pointer...

... which points to s0 being written past its end

You may have some luck by using gdb's watch command, 

`watch EXPR'
     Set a watchpoint for an expression.  GDB will break when EXPR is
     written into by the program and its value changes.  This can be

Andy

---------------------------------------------------------------
Next TLUG Nomikai: 11 March Wed 1998 Tengu TokyoEkiMae 19:30
Chuo-ku, Kyobashi 1-1-6, EchiZenYa Bld. B1/B2 03-3275-3691
Next TLUG Meeting: 11 April 1998 Saturday, Tokyo Station
Featuring Tague Griffith of Netscape i18n talking on source code
---------------------------------------------------------------
a word from the sponsor:
TWICS - Japan's First Public-Access Internet System
www.twics.com  info@example.com  Tel:03-3351-5977  Fax:03-3353-6096



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links