Date: Tue, 30 Jul 2002 10:36:55 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Patrick Chen cc: djgpp AT delorie DOT com Subject: Re: fread can't read a second time. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 30 Jul 2002, Patrick Chen wrote: > I have this weird problem. The first block will load a red.bmp, open > it, get the header, pass it to process ld_memtofile along with fin to close > it inside the function. Without the second block of open&process green.bmp, > mb[0]->data[234} sample, did receive the right value. > When I put the second block to process the green.bmp, > SIGSEGV general protection fault occur at the fread of the second block. It > cannot transfer the data from green.bmp to file_header_ex2 even though > fileheader_ex2 is a new char array with new fin2 which is not 0. Can some > good people explain why this can happen and how to solve it? I suspect that the cause of the problem is inside the function ld_filetomem whose source you didn't show, or in the arguments you pass to that function. One thing that surely looks suspicious is this declaration: MOUSEBITMAP *mb[1]; and the fact that you pass &mb[0] and &mb[1] to ld_filetomem. For starters, if mb[] has only one element, you aren't allowed to reference mb[1], so the above declaration should probably say mb[2]. Also, since mb[] is an array of pointers, do you really mean to pass the address of mb[0] and mb[1]?