From 8aef3fa98a1ac218a3f69ae14dc938c6ba0c9707 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Thu, 25 Jul 2013 13:08:18 +0100 Subject: [PATCH] Guard against trying to allocate 0 outputs. Signed-off-by: Chris Michael --- src/lib/ecore_x/xlib/ecore_x_randr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c b/src/lib/ecore_x/xlib/ecore_x_randr.c index 8ba1692f51..235cf4877b 100644 --- a/src/lib/ecore_x/xlib/ecore_x_randr.c +++ b/src/lib/ecore_x/xlib/ecore_x_randr.c @@ -1109,7 +1109,7 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window, int *num) XRRScreenResources *res = NULL; Ecore_X_Randr_Crtc *ret = NULL; - if (ncrtcs <= 0) + if (ncrtcs < 1) { free(crtcs); return NULL; @@ -1695,10 +1695,13 @@ ecore_x_randr_crtc_settings_set(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc, Ec 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; + if (noutputs > 0) + { + routputs = malloc(noutputs * sizeof(RROutput)); + for (i = 0; i < noutputs; i++) + routputs[i] = info->outputs[i]; + need_free = EINA_TRUE; + } } else if (noutputs > 0) {