princeamd pushed a commit to branch ecore-1.7.
commit 82a9771df0c8b233487a15a4eeaafaa20c1d978f
Author: Chris Michael <[email protected]>
Date: Tue May 21 14:29:37 2013 +0100
Backport: afff55e :: Fix memleak in ecore_x_randr_crtc_settings_set.
Signed-off-by: Chris Michael <[email protected]>
Signed-off-by: Deon Thomas <[email protected]>
---
src/lib/ecore_x/xlib/ecore_x_randr.c | 68 ++++++++++++++++++++++--------------
1 file changed, 42 insertions(+), 26 deletions(-)
diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c
b/src/lib/ecore_x/xlib/ecore_x_randr.c
index 1cfc571..d0bae16 100644
--- a/src/lib/ecore_x/xlib/ecore_x_randr.c
+++ b/src/lib/ecore_x/xlib/ecore_x_randr.c
@@ -1648,43 +1648,59 @@ ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc, Ec
/* try to get the screen resources from Xrandr */
if ((res = _ecore_x_randr_screen_resources_get(_ecore_x_disp, root)))
{
+ RRCrtc rcrtc;
+ RROutput *routputs = NULL;
XRRCrtcInfo *info = NULL;
+ Eina_Bool need_free = EINA_FALSE;
+ int i = 0;
+
+ rcrtc = (RRCrtc)crtc;
/* try to get crtc info for original crtc */
- if ((info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
+ if (!(info = XRRGetCrtcInfo(_ecore_x_disp, res, rcrtc)))
{
- if ((mode == 0) || (noutputs == 0))
- {
- outputs = NULL;
- noutputs = 0;
- }
- else if (noutputs == -1)
- {
- outputs = (Ecore_X_Randr_Output *)info->outputs;
- noutputs = info->noutput;
- }
-
- /* safety check some values */
- if ((int)mode == -1) mode = info->mode;
- if ((int)orientation == -1) orientation = info->rotation;
- if (x < 0) x = info->x;
- if (y < 0) y = info->y;
+ /* free the resources */
+ XRRFreeScreenResources(res);
+ return EINA_FALSE;
+ }
- /* try to set the crtc config */
- if (!XRRSetCrtcConfig(_ecore_x_disp, res, crtc, CurrentTime,
- x, y, mode, orientation,
- (RROutput *)outputs, noutputs))
- ret = EINA_TRUE;
+ if ((int)mode == -1) mode = info->mode;
+ if ((int)orientation == -1) orientation = info->rotation;
+ if (x < 0) x = info->x;
+ if (y < 0) y = info->y;
- /* free the crtc info */
- XRRFreeCrtcInfo(info);
+ if (noutputs < 0)
+ {
+ noutputs = info->noutput;
+ routputs = malloc(noutputs * sizeof(RROutput));
+ for (i = 0; i < noutputs; i++)
+ routputs[i] = info->outputs[i];
+ need_free = EINA_TRUE;
+ }
+ else if (noutputs > 0)
+ {
+ routputs = malloc(noutputs * sizeof(RROutput));
+ for (i = 0; i < noutputs; i++)
+ routputs[i] = (RROutput)outputs[i];
+ need_free = EINA_TRUE;
}
+ /* try to set the crtc config */
+ if (!XRRSetCrtcConfig(_ecore_x_disp, res, rcrtc, CurrentTime,
+ x, y, mode, orientation,
+ routputs, noutputs))
+ ret = EINA_TRUE;
+
+ if (need_free) free(routputs);
+
+ /* free the crtc info */
+ XRRFreeCrtcInfo(info);
+
/* free the resources */
XRRFreeScreenResources(res);
-
- return ret;
}
+
+ return ret;
#endif
return EINA_FALSE;
}
--
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev