X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <4166513D.92D782BF@yahoo.com> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Free() crash my program! References: <41663c2c$0$179$cc7c7865 AT news DOT luth DOT se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 40 Date: Fri, 08 Oct 2004 08:57:58 GMT NNTP-Posting-Host: 12.76.132.39 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1097225878 12.76.132.39 (Fri, 08 Oct 2004 08:57:58 GMT) NNTP-Posting-Date: Fri, 08 Oct 2004 08:57:58 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Martin Str|mberg wrote: > JC wrote: > >> I used djgpp to develop a simple program, using dosmemget(), >> to dump some DOS memory. The code is like following: > >> p = (UINT8 *)malloc(len+1); >> if (p == NULL) >> { >> ... >> } >> dosmemget(addr, len, p); >> /* Code to printf the contents in *p */ >> ... >> free(p); > >> The code compiled & ran fine. But when the code execute >> the free(). The code crashed and got SIGSEG error: > >> Exiting due to signal SIGSEGV >> General Protection Fault at eip=00006ac4 > >> Anyone can help me on this? > > 1. Remove that UINT8 * cast. > > 2. If that doesn't help you need to give more information, because > malloc() and free() work fine so it must be something else. Shouldn't there be some limit on the len parameter? Just considering the nature of the DOS memory addressing, I would expect it to not work for anything over 65535. But that cast certainly has to go. -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net) Available for consulting/temporary embedded and systems. USE worldnet address!