Be a bit more pedantic when getting outputs for a crtc, in that if
authorChristopher Michael <cp.michael@samsung.com>
Tue, 5 Feb 2013 10:51:57 +0000 (10:51 +0000)
committerChristopher Michael <cpmichael1@comcast.net>
Tue, 5 Feb 2013 10:51:57 +0000 (10:51 +0000)
xrandr returns 0 outputs, then free resources and return null quickly.

Signed-off-by: Christopher Michael <cp.michael@samsung.com>
SVN revision: 83623

src/lib/ecore_x/xlib/ecore_x_randr.c

index 33c0ffc..bdcf8a0 100644 (file)
@@ -1135,6 +1135,18 @@ ecore_x_randr_crtc_outputs_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, int
         /* try to get crtc info */
         if ((info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
           {
+             /* if we have no outputs, return NULL */
+             if (info->noutput == 0)
+               {
+                  /* free the crtc info */
+                  XRRFreeCrtcInfo(info);
+
+                  /* free the resources */
+                  XRRFreeScreenResources(res);
+
+                  return NULL;
+               }
+
              /* try to allocate our return struct */
              if ((ret = malloc(info->noutput * sizeof(Ecore_X_Randr_Output))))
                {