]> diplodocus.org Git - xorg-xinput/commitdiff
Don't leak output_info
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 17 Feb 2012 03:23:08 +0000 (13:23 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 21 Feb 2012 01:19:17 +0000 (11:19 +1000)
This inverts the logic to have a more obvious flow for freeing the
output_info.

==26716== 1,161 bytes in 8 blocks are definitely lost in loss record 5 of 7
==26716==    at 0x4A074CD: malloc (vg_replace_malloc.c:236)
==26716==    by 0x395D804ABA: XRRGetOutputInfo (in /usr/lib64/libXrandr.so.2.2.0)
==26716==    by 0x40932B: map_output_xrandr (transform.c:150)
==26716==    by 0x40982F: map_to_output (transform.c:263)
==26716==    by 0x4070A4: main (xinput.c:386)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/transform.c

index 7717ffbf10c812aab6eb83dbdd879df209bd960f..3ea7ff85e98cc213d87134213aeabeae15a2e2b7 100644 (file)
@@ -148,14 +148,15 @@ map_output_xrandr(Display *dpy, int deviceid, const char *output_name)
     for (i = 0; i < res->noutput && !found; i++)
     {
         output_info = XRRGetOutputInfo(dpy, res, res->outputs[i]);
     for (i = 0; i < res->noutput && !found; i++)
     {
         output_info = XRRGetOutputInfo(dpy, res, res->outputs[i]);
-        if (!output_info->crtc || output_info->connection != RR_Connected)
-            continue;
 
 
-        if (strcmp(output_info->name, output_name) == 0)
+        if (output_info->crtc && output_info->connection == RR_Connected &&
+            strcmp(output_info->name, output_name) == 0)
         {
             found = 1;
             break;
         }
         {
             found = 1;
             break;
         }
+
+        XRRFreeOutputInfo(output_info);
     }
 
     /* crtc holds our screen info, need to compare to actual screen size */
     }
 
     /* crtc holds our screen info, need to compare to actual screen size */
@@ -169,6 +170,7 @@ map_output_xrandr(Display *dpy, int deviceid, const char *output_name)
                                   crtc_info->width, crtc_info->height);
         rc = apply_matrix(dpy, deviceid, &m);
         XRRFreeCrtcInfo(crtc_info);
                                   crtc_info->width, crtc_info->height);
         rc = apply_matrix(dpy, deviceid, &m);
         XRRFreeCrtcInfo(crtc_info);
+        XRRFreeOutputInfo(output_info);
     } else
         printf("Unable to find output '%s'. "
                 "Output may not be connected.\n", output_name);
     } else
         printf("Unable to find output '%s'. "
                 "Output may not be connected.\n", output_name);