From aa88c5697d3d45a1db27ed7d6de770f79b4aadf5 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Fri, 7 Sep 2012 13:12:30 +0000 Subject: [PATCH] Ecore_X (RandR): Fix long outstanding randr bug which caused ecore_x_randr to not work for pretty much everyone. Short version, don't memcpy something potentially Larger into something Certainly smaller. (read on for the details). NB: This 'should' fix all the randr problems in ecore_x (tho I have not tested Everything). NB: Ok, here goes: XRRGetScreenResources returns a struct. Inside that struct is a list of RROutputs. RROutput is defined as (from randrproto.h): #define RROutput CARD32 CARD32 is defined as (from X11/Xmd.h): # ifdef LONG64 typedef unsigned long CARD64; typedef unsigned int CARD32; # else typedef unsigned long CARD32; # endif so CARD32 can change based on the system (32/64 bit). Ecore_X_Randr_Output is defined as (Ecore_X.h): typedef Ecore_X_ID Ecore_X_Randr_Output; (for reference: typedef unsigned int Ecore_X_ID) Double bonus points if you have already spotted the problem !! ;) SVN revision: 76306 --- legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c index 3be89ac1d5..b839736a88 100644 --- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c +++ b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c @@ -642,10 +642,12 @@ ecore_x_randr_outputs_get(Ecore_X_Window root, { if ((ret = malloc(sizeof(Ecore_X_Randr_Output) * res->noutput))) { - memcpy(ret, res->outputs, - (sizeof(Ecore_X_Randr_Output) * res->noutput)); - if (num) - *num = res->noutput; + int i = 0; + + if (num) *num = res->noutput; + + for (i = 0; i < res->noutput; i++) + ret[i] = res->outputs[i]; } if (res)