summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-02-08 20:46:29 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-02-09 02:46:53 +1000
commitc591231a666d8dfdac4d301c0de49f34ac3e4aac (patch)
tree5b6232d2c9cfb6aede0749f1827296e825b6e27a
parenta0e4d4e1067de2a25e05272238a8503691c5b01a (diff)
Fix XRRCrtcInfo memory leaks
crtc_info isn't used until later, move down to the block it is used to avoid leaking. Reported-by: Aaron Plattner <aplattner@nvidia.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
-rw-r--r--src/transform.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/transform.c b/src/transform.c
index cffc3af..6a31c83 100644
--- a/src/transform.c
+++ b/src/transform.c
@@ -142,7 +142,6 @@ map_output_xrandr(Display *dpy, int deviceid, const char *output_name)
int rc = EXIT_FAILURE;
XRRScreenResources *res;
XRROutputInfo *output_info;
- XRRCrtcInfo *crtc_info;
res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy));
@@ -152,7 +151,6 @@ map_output_xrandr(Display *dpy, int deviceid, const char *output_name)
if (!output_info->crtc || output_info->connection != RR_Connected)
continue;
- crtc_info = XRRGetCrtcInfo (dpy, res, output_info->crtc);
if (strcmp(output_info->name, output_name) == 0)
{
found = 1;
@@ -163,11 +161,14 @@ map_output_xrandr(Display *dpy, int deviceid, const char *output_name)
/* crtc holds our screen info, need to compare to actual screen size */
if (found)
{
+ XRRCrtcInfo *crtc_info;
Matrix m;
matrix_set_unity(&m);
+ crtc_info = XRRGetCrtcInfo (dpy, res, output_info->crtc);
set_transformation_matrix(dpy, &m, crtc_info->x, crtc_info->y,
crtc_info->width, crtc_info->height);
rc = apply_matrix(dpy, deviceid, &m);
+ XRRFreeCrtcInfo(crtc_info);
} else
printf("Unable to find output '%s'. "
"Output may not be connected.\n", output_name);