Re: [AD] Bug in unstable developers release, sound.c |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> I have come across a bug in the unstable developers release stream (at
> least 4.1.4-4.1.9) in the file src/sound.c.
Note that Chris Jones changed the type of 's' from 'signed short' to 'int' in
the 4.1.5 release.
> In the function 'load_wav' (line 951 of the 4.1.9 source), a signed short
> is compared against EOF, and will prematurely stop if it encounters valid
> data of -1. This only occurs on 16 bit data.
This bug did exist in the 4.1.4 release but was fixed in the 4.1.5 by Chris.
> Also, in line 944, the result of a 'pack_fread' is compared to the wrong
> variable, though it would only matter on a truncated stereo 8 bit wav file.
Confirmed, my fault. Thanks for spotting it!
> The stable releases are unaffected
Yes, thanks for checking.
> --- 940,956 ----
> spl = create_sample(bits, ((channels == 2) ? TRUE : FALSE), freq,
> len);
>
> if (spl) {
> ! if (pack_fread(spl->data, length, f) < length) {
> destroy_sample(spl);
> spl = NULL;
> ! goto getout;
> }
> ! if(bits == 16) {
> ! p = (unsigned short *)spl->data;
> ! i = length / 2;
> ! while(i--)
> ! *p++ ^= 0x8000;
> }
> length = 0;
> }
> }
The 16-bit part doesn't work for big-endian CPUs, which we try to support as
much as possible. 16-bit WAV files are stored in little-endian format (Intel
format, hence the use of pack_igetw) while Allegro's internal buffers are
supposed to be stored in native format.
--
Eric Botcazou