[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Bug in sndarray.c



hi,

thanks heaps for this.

Are you able to make a patch against svn pygame?
http://pygame.org/wiki/cvs

svn co svn://seul.org/svn/pygame/trunk pygame_trunk

Also, if you have a little test case that would also be helpful.

If you can't do either of these, someone else should be able to have a
look at it at some point.

Thanks again!

cheers,




On Thu, Aug 28, 2008 at 1:03 PM, Eyal Lotem <eyal.lotem@xxxxxxxxx> wrote:
> (Please CC me for all correspondence, thanks)
>
> In pygame 1.7.1release-4.1ubuntu1 (Ubuntu Hardy's version), there is a
> bug where 64-bit machines cannot use sndarray_make_sound, as the data
> isn't copied, and instead garbage is inserted to the result sound
> object.
>
> The function sndarray.c: sndarray_make_sound assumes that the given
> arrays' elements sizes will be 1, 2 or 4.  It also unnecessarily casts
> the pointers both before and after dereferences.  This unnecessarily
> differentiated between otherwise identical handling of the differing
> sizes, which causes the need for the cases in the first place.
>
> Perhaps the reason behind the cases was allowing compiler
> optimization, but apparently it is too risky (bug-wise).
>
> The "cheap" way out would be to add the case for size=8, but that
> would break too upon other word-sized machines.  If this cheap
> solution is chosen, its probably a good idea to add a "default" case
> which errorizes.  Also, this isn't very optimal, as the switch-case
> can be put out of the heavier loop over all the samples (it is
> re-checked for every sample, so its not very optimized anyhow!).
>
> The simplifying/fixing patch is attached.
>