summaryrefslogtreecommitdiff
path: root/legacy
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
parentb0907e89b84a3ba199ab2b784144246ee747b0e7 (diff)
fix randr segv's waiting to happen. bad mem managment :(
SVN revision: 70951
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ecore/ChangeLog5
-rw-r--r--legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c21
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c21
3 files changed, 35 insertions, 12 deletions
diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog
index 85eee6d424..4dfe9daed8 100644
--- a/legacy/ecore/ChangeLog
+++ b/legacy/ecore/ChangeLog
@@ -640,3 +640,8 @@
6402012-05-10 Jiyoun Park 6402012-05-10 Jiyoun Park
641 641
642 * Send mouse move event before mouse down event in ecore_extn 642 * Send mouse move event before mouse down event in ecore_extn
643
6442012-05-13 Carsten Haitzler (The Rasterman)
645
646 * Fix ecore-x randr issues with memory access when building
647 output arrays which are memory segv bugs waiting to crash.
diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c
index a07e286695..c471dba6fb 100644
--- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c
+++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c
@@ -1628,7 +1628,7 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
1628 1628
1629 root = ecore_x_window_root_get(window); 1629 root = ecore_x_window_root_get(window);
1630 crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs); 1630 crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
1631 if (!crtcs) return NULL; 1631 if (!crtcs) goto _ecore_x_randr_window_crtcs_get_fail;
1632 1632
1633 /* now get window RELATIVE to root window - thats what matters. */ 1633 /* now get window RELATIVE to root window - thats what matters. */
1634 cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0); 1634 cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0);
@@ -1637,6 +1637,12 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
1637 w_geo.y = trans->dst_y; 1637 w_geo.y = trans->dst_y;
1638 free(trans); 1638 free(trans);
1639 1639
1640 ret = calloc(1, ncrtcs * sizeof(Ecore_X_Randr_Crtc));
1641 if (!ret)
1642 {
1643 free(crtcs);
1644 goto _ecore_x_randr_window_crtcs_get_fail;
1645 }
1640 for (i = 0, nret = 0; i < ncrtcs; i++) 1646 for (i = 0, nret = 0; i < ncrtcs; i++)
1641 { 1647 {
1642 /* if crtc is not enabled, don't bother about it any further */ 1648 /* if crtc is not enabled, don't bother about it any further */
@@ -1647,9 +1653,8 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
1647 &c_geo.w, &c_geo.h); 1653 &c_geo.w, &c_geo.h);
1648 if (eina_rectangles_intersect(&w_geo, &c_geo)) 1654 if (eina_rectangles_intersect(&w_geo, &c_geo))
1649 { 1655 {
1650 ret = realloc(ret, (++nret *
1651 sizeof(Ecore_X_Randr_Output)));
1652 ret[nret] = crtcs[i]; 1656 ret[nret] = crtcs[i];
1657 nret++;
1653 } 1658 }
1654 } 1659 }
1655 free(crtcs); 1660 free(crtcs);
@@ -1657,6 +1662,7 @@ ecore_x_randr_window_crtcs_get(Ecore_X_Window window,
1657 if (num) *num = nret; 1662 if (num) *num = nret;
1658 return ret; 1663 return ret;
1659 1664
1665_ecore_x_randr_window_crtcs_get_fail:
1660#endif 1666#endif
1661 if (num) *num = 0; 1667 if (num) *num = 0;
1662 return NULL; 1668 return NULL;
@@ -2442,7 +2448,7 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2442#ifdef ECORE_XCB_RANDR 2448#ifdef ECORE_XCB_RANDR
2443 Ecore_X_Window root; 2449 Ecore_X_Window root;
2444 Ecore_X_Randr_Crtc *crtcs; 2450 Ecore_X_Randr_Crtc *crtcs;
2445 Ecore_X_Randr_Output *outputs, *ret = NULL; 2451 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
2446 int ncrtcs, noutputs, i, nret = 0; 2452 int ncrtcs, noutputs, i, nret = 0;
2447#endif 2453#endif
2448 2454
@@ -2465,10 +2471,13 @@ ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2465 &noutputs); 2471 &noutputs);
2466 if (!outputs) 2472 if (!outputs)
2467 goto _ecore_x_randr_current_output_get_fail_free; 2473 goto _ecore_x_randr_current_output_get_fail_free;
2468 nret += noutputs; 2474 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
2469 ret = realloc(ret, (nret * sizeof(Ecore_X_Randr_Output))); 2475 if (!tret) goto _ecore_x_randr_current_output_get_fail_free;
2476 ret = tret;
2470 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output))); 2477 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
2478 nret += noutputs;
2471 free(outputs); 2479 free(outputs);
2480 outputs = NULL;
2472 } 2481 }
2473 free(crtcs); 2482 free(crtcs);
2474 2483
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 8ec75cdf24..82fa6b7396 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