summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_x/xlib
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-05-13 01:06:01 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-05-13 01:06:01 +0000
commit262e8118b76274565d53622c075a6048ffad4453 (patch)
tree3271391e7d26eb412b5452d377d280a33c3f5871 /legacy/ecore/src/lib/ecore_x/xlib
parentb0907e89b84a3ba199ab2b784144246ee747b0e7 (diff)
fix randr segv's waiting to happen. bad mem managment :(
SVN revision: 70951
Diffstat (limited to 'legacy/ecore/src/lib/ecore_x/xlib')
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
index 8ec75cd..82fa6b7 100644
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
+++ b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
@@ -596,6 +596,12 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
596 w_geo.x = rx; 596 w_geo.x = rx;
597 w_geo.y = ry; 597 w_geo.y = ry;
598 598
599 ret = calloc(1, ncrtcs * sizeof(Ecore_X_Randr_Crtc));
600 if (!ret)
601 {
602 free(crtcs);
603 goto _ecore_x_randr_window_crtcs_get_fail;
604 }
599 for (i = 0, nret = 0; i < ncrtcs; i++) 605 for (i = 0, nret = 0; i < ncrtcs; i++)
600 { 606 {
601 /* if crtc is not enabled, don't bother about it any further */ 607 /* if crtc is not enabled, don't bother about it any further */
@@ -607,8 +613,8 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
607 &c_geo.w, &c_geo.h); 613 &c_geo.w, &c_geo.h);
608 if (eina_rectangles_intersect(&w_geo, &c_geo)) 614 if (eina_rectangles_intersect(&w_geo, &c_geo))
609 { 615 {
610 ret = realloc(ret, (sizeof(Ecore_X_Randr_Crtc) * ++nret));
611 ret[nret] = crtcs[i]; 616 ret[nret] = crtcs[i];
617 nret++;
612 } 618 }
613 } 619 }
614 free(crtcs); 620 free(crtcs);
@@ -2337,7 +2343,7 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2337#ifdef ECORE_XRANDR 2343#ifdef ECORE_XRANDR
2338 Ecore_X_Window root; 2344 Ecore_X_Window root;
2339 Ecore_X_Randr_Crtc *crtcs; 2345 Ecore_X_Randr_Crtc *crtcs;
2340 Ecore_X_Randr_Output *outputs, *ret = NULL; 2346 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
2341 int ncrtcs, noutputs, i, nret = 0; 2347 int ncrtcs, noutputs, i, nret = 0;
2342 2348
2343 if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail; 2349 if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
@@ -2345,18 +2351,21 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2345 root = ecore_x_window_root_get(window); 2351 root = ecore_x_window_root_get(window);
2346 if (!(crtcs = ecore_x_randr_window_crtcs_get(window, &ncrtcs))) 2352 if (!(crtcs = ecore_x_randr_window_crtcs_get(window, &ncrtcs)))
2347 goto _ecore_x_randr_current_output_get_fail; 2353 goto _ecore_x_randr_current_output_get_fail;
2348 2354
2349 for (i = 0, nret = 0; i < ncrtcs; i++) 2355 for (i = 0, nret = 0; i < ncrtcs; i++)
2350 { 2356 {
2351 2357
2352 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i], 2358 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
2353 &noutputs); 2359 &noutputs);
2354 if (!outputs) 2360 if (!outputs)
2355 goto _ecore_x_randr_current_output_get_fail_free; 2361 goto _ecore_x_randr_current_output_get_fail_free;
2356 nret += noutputs; 2362 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
2357 ret = realloc(ret, (nret * sizeof(Ecore_X_Randr_Output))); 2363 if (!tret) goto _ecore_x_randr_current_output_get_fail_free;
2364 ret = tret;
2358 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output))); 2365 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
2366 nret += noutputs;
2359 free(outputs); 2367 free(outputs);
2368 outputs = NULL;
2360 } 2369 }
2361 free(crtcs); 2370 free(crtcs);
2362 2371