Mailing List Archive

Support open source code!


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

Re: tlug: more gcc crap



>
>Ok, suppose I have a variable:
>
>char *s0;
>
>it's been malloced with
>
>s0=(char *)malloc(80);
>
>The function it's in does:
>
>sprintf(s0,"some_text %s some_text",some_other_string_var);
>newtWinMessage("Title","Ok",s0);
>




I had the same problem and solved it by truncating some_other_string_var
with the exact size of 80 bytes. sprintf generally stops at the first null
terminator in a variable. If that is exceeded then s0 has an allocation
overflow which will result in Segment Fault.

Let me know if that works !!




>(everything works just fine so far).
>
>Then I have a line:
>
>if (s0) free(s0);
>
>This causes a segmentation fault.  gdb output is:
>
>Breakpoint 1, doFindPackages (state=0x806a4d8) at turboupgrade.c:261
>261             if (s0) free(s0);
>(gdb) n
>
>Program received signal SIGSEGV, Segmentation fault.
>0x400ed7a9 in __libc_free ()
>
>
>what the heck causes something like this?  It seems like the if clause
>would prevent this sort of crap.. it's acting like I'm trying to free an
>un-malloced pointer...
>
>--------------------------------------------------
>Scott M. Stone <sstone@example.com, sstone@example.com>
>               <sstone@example.com>
>Linux Developer/Systems Administrator for Pacific HiTech, Inc.
>http://www.pht.com http://armadillo.pht.co.jp
>http://www.pht.co.jp         http://www.turbolinux.com
>
>
>---------------------------------------------------------------
>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
>

---------------------------------------------------------------
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