On Tue, Mar 1, 2011 at 4:33 PM, Peter Hutterer <peter.hutte...@who-t.net>wrote:

> Not 100% sure why this is needed but it looks like the returned address is
> invalid, causing memory corruption. Simply moving the variable into a
> global
> scope fixes this issue.
>
> Fixes crash with server 1.7.
>
> Reported-by: Vu Ngoc San <san.vu-n...@laposte.net>
> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
> ---
>  src/wcmCommon.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index e469e15..64e10cc 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -36,9 +36,9 @@
>  * data beforehand.
>  */
>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 11
> +static int v[MAX_VALUATORS];
>  static int *VCOPY(const int *valuators, int nvals)
>  {
> -       static int v[MAX_VALUATORS];
>        memcpy(v, valuators, nvals * sizeof(int));
>        return v;
>

Once the routine is returned, the pointer is out of the scope.

To return a valid pointer, the array has to be declared outside of VCOPY.
You could declare it in the calling routine if you don't like it as a global
variable.

With that said,

Reviewed-by: Ping Cheng <pingli...@gmail.com>

Ping
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to