delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/27/13:01:23

From: Bjorn De Meyer <bgdmeyer AT eduserv2 DOT rug DOT ac DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Error in BCD
Date: Mon, 27 Apr 1998 17:45:36 +0200
Organization: University of Ghent, Belgium
Lines: 53
Message-ID: <Pine.GSO.3.96.980427174157.20692A-100000@eduserv2.rug.ac.be>
References: <35448FC4 DOT 62833427 AT gmx DOT net>
NNTP-Posting-Host: eduserv2.rug.ac.be
Mime-Version: 1.0
In-Reply-To: <35448FC4.62833427@gmx.net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 27 Apr 1998, Lennart Poettering wrote:

> I think i have found a heavy error in BCD (The only CDROM-library for
> DJGPP): BCD doesn't alloc anough memory for its track-list:
> it will write intro memory as long as this error is not fixed. this will
> cause break downs of programs written with bcd on places nobody expects. 
> 
> int "bcd_get_audio_info" you will find the following code: (roundabout
> line 460)
> 
>   tracks = calloc(num_tracks, sizeof(Track));
>   if (tracks == NULL) {
>     _bcd_error = "Out of memory allocating tracks\n";
>     return 0;
> 
> With these lines bcd allocs - correctly - enough memory for storing all
> track information. but later it uses as index for the array "tracks" 1.
> this causes, that BCD writes an overhead of one track-entry intro the
> table.
> 
> you can fix this - it is not elegant, i know - with the following change
>   tracks = calloc(num_tracks+1, sizeof(Track));
> 
> than everything works fine....

Or if you are sure that tracks[0] is never used do a

 tracks--;

This will decrement the pointer to point
one adress before the allocated memory starts, making 1 a valid lower
value, but disabling the use of Track[0]. I hope this is more elegant.




Bjorn De Meyer.
IA #i^4
Homepage: http//studwww.rug.ac.be/~bgdmeyer
E-mail: bjorn DOT demeyer AT rug DOT ac DOT be 
Chemistry student at RUG, option polymers.
Coordinator of the "Tales of Artah: First Sword" CRPG project.         
  
 "I've shaven. I'm happy. I have no religion. Don't pray for me." 
                                                Illusion of Gaia 2
         
                                   

        
              
                                   
            

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019