raster pushed a commit to branch master.

commit e945f0d19654d153a626ff6627d2bbf36191cef8
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Wed Jul 24 19:22:31 2013 +0900

    ecore-x: fix randr query when noutputs is 0.
---
 src/lib/ecore_x/xcb/ecore_xcb_randr.c | 22 +++++++++++++---------
 src/lib/ecore_x/xlib/ecore_x_randr.c  | 20 +++++++++++---------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/lib/ecore_x/xcb/ecore_xcb_randr.c 
b/src/lib/ecore_x/xcb/ecore_xcb_randr.c
index a429b35..d74644c 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_randr.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_randr.c
@@ -2672,15 +2672,19 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
 
         outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
               &noutputs);
-        if (!outputs)
-          goto _ecore_x_randr_current_output_get_fail_free;
-        tret = realloc(ret, ((nret + noutputs) * 
sizeof(Ecore_X_Randr_Output)));
-        if (!tret) goto _ecore_x_randr_current_output_get_fail_free;
-        ret = tret;
-        memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
-        nret += noutputs;
-        free(outputs);
-        outputs = NULL;
+        if (outputs)
+          {
+             if (noutputs > 0)
+               {
+                  tret = realloc(ret, ((nret + noutputs) * 
sizeof(Ecore_X_Randr_Output)));
+                  if (!tret) goto _ecore_x_randr_current_output_get_fail_free;
+                  ret = tret;
+                  memcpy(&ret[nret], outputs, (noutputs * 
sizeof(Ecore_X_Randr_Output)));
+                  nret += noutputs;
+               }
+             free(outputs);
+             outputs = NULL;
+          }
      }
    free(crtcs);
 
diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c 
b/src/lib/ecore_x/xlib/ecore_x_randr.c
index 4761732..ef1ea40 100644
--- a/src/lib/ecore_x/xlib/ecore_x_randr.c
+++ b/src/lib/ecore_x/xlib/ecore_x_randr.c
@@ -1034,17 +1034,19 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window, 
int *num)
                   /* try to get the crtc info for this crtc */
                   if (!(crtc = XRRGetCrtcInfo(_ecore_x_disp, res, crtcs[i])))
                     continue;
-
-                  /* try to reallocate our return variable */
-                  if ((tret = realloc(ret, ((nret + crtc->noutput) * 
-                                            sizeof(Ecore_X_Randr_Output)))))
+                  
+                  if (crtc->noutput > 0)
                     {
-                       ret = tret;
-                       memcpy(&ret[nret], crtc->outputs, 
-                              (crtc->noutput * sizeof(Ecore_X_Randr_Output)));
-                       nret += crtc->noutput;
+                       /* try to reallocate our return variable */
+                       if ((tret = realloc(ret, ((nret + crtc->noutput) * 
+                                                 
sizeof(Ecore_X_Randr_Output)))))
+                         {
+                            ret = tret;
+                            memcpy(&ret[nret], crtc->outputs, 
+                                   (crtc->noutput * 
sizeof(Ecore_X_Randr_Output)));
+                            nret += crtc->noutput;
+                         }
                     }
-
                   /* free the crtc info */
                   XRRFreeCrtcInfo(crtc);
                }

-- 

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

Reply via email to