Re: [Plib-devel] Linux joystick crash and fix.
Brought to you by:
sjbaker
From: Bram S. <br...@sa...> - 2005-02-21 07:38:30
|
Mathias, I've committed your patch to the CVS repository. I recall having seen this patch a month ago or so, but I assume it was dropped then for no appearant reasons? Bram On 02/21/05 07:45:10, Mathias Fr=C3=B6hlich wrote: >=20 > Hi, >=20 > If a joystick has more than _JS_MAX_AXES axes, the JSIOCGCORR ioctl > will > crash. > Attached is a fix to that by making the data dynamic allocated with > the > correct size. >=20 > Please apply! >=20 > Greetings >=20 > Mathias >=20 > -- > Mathias Fr=C3=B6hlich, email: Mat...@gm... > > Index: src/js/jsLinux.cxx > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/plib/plib/src/js/jsLinux.cxx,v > retrieving revision 1.6 > diff -u -r1.6 jsLinux.cxx > --- src/js/jsLinux.cxx 20 Oct 2004 23:49:33 -0000 1.6 > +++ src/js/jsLinux.cxx 3 Feb 2005 18:24:56 -0000 > @@ -75,12 +75,13 @@ > ioctl ( os->fd, JSIOCGNAME ( sizeof(name) ), name ) ; > fcntl ( os->fd, F_SETFL , O_NONBLOCK ) ; >=20 > + int all_axes =3D num_axes; > if ( num_axes > _JS_MAX_AXES ) > num_axes =3D _JS_MAX_AXES ; >=20 > // Remove any deadband value already done in the kernel. > // Since we have our own deadband management this is save to do > so. > - struct js_corr corr [ _JS_MAX_AXES ] ; > + struct js_corr* corr =3D new js_corr[ all_axes ] ; > ioctl ( os->fd, JSIOCGCORR, corr ); > for ( int i =3D 0; i < num_axes ; ++i ) { > if ( corr[ i ] . type =3D=3D JS_CORR_BROKEN ) { > @@ -90,6 +91,7 @@ > } > } > ioctl ( os->fd, JSIOCSCORR, corr ); > + delete[] corr; >=20 > for ( int i =3D 0 ; i < _JS_MAX_AXES ; i++ ) > { >=20 |