summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2013-01-03 06:56:42 +0000
committerCarsten Haitzler <raster@rasterman.com>2013-01-03 06:56:42 +0000
commit90bc1aa27cd4c4b1e4fa8a1feba17e5435b9210a (patch)
tree4ac3756e034bcb2d3f36f1ba06eea366f2a0fc2b /src
parent5cf84bb84ada215b68f575b109a427a00df235bb (diff)
fix ecore-con client double-free case
SVN revision: 82042
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_con/ecore_con.c82
1 files changed, 61 insertions, 21 deletions
diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index c7e47bbef3..aaa880e32f 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -2364,15 +2364,23 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
2364 e = ev; 2364 e = ev;
2365 if (e->client) 2365 if (e->client)
2366 { 2366 {
2367 Eina_Bool svrfreed = EINA_FALSE;
2368
2367 e->client->event_count = eina_list_remove(e->client->event_count, e); 2369 e->client->event_count = eina_list_remove(e->client->event_count, e);
2368 if (e->client->host_server) 2370 if (e->client->host_server)
2369 { 2371 {
2370 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev); 2372 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev);
2371 if ((!svr->event_count) && (svr->delete_me)) 2373 if ((!svr->event_count) && (svr->delete_me))
2372 _ecore_con_server_free(svr); 2374 {
2375 _ecore_con_server_free(svr);
2376 svrfreed = EINA_TRUE;
2377 }
2378 }
2379 if (!svrfreed)
2380 {
2381 if ((!e->client->event_count) && (e->client->delete_me))
2382 ecore_con_client_del(e->client);
2373 } 2383 }
2374 if ((!e->client->event_count) && (e->client->delete_me))
2375 ecore_con_client_del(e->client);
2376 } 2384 }
2377 2385
2378 ecore_con_event_client_add_free(e); 2386 ecore_con_event_client_add_free(e);
@@ -2390,15 +2398,23 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
2390 e = ev; 2398 e = ev;
2391 if (e->client) 2399 if (e->client)
2392 { 2400 {
2401 Eina_Bool svrfreed = EINA_FALSE;
2402
2393 e->client->event_count = eina_list_remove(e->client->event_count, e); 2403 e->client->event_count = eina_list_remove(e->client->event_count, e);
2394 if (e->client->host_server) 2404 if (e->client->host_server)
2395 { 2405 {
2396 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev); 2406 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev);
2397 if ((!svr->event_count) && (svr->delete_me)) 2407 if ((!svr->event_count) && (svr->delete_me))
2398 _ecore_con_server_free(svr); 2408 {
2409 _ecore_con_server_free(svr);
2410 svrfreed = EINA_TRUE;
2411 }
2412 }
2413 if (!svrfreed)
2414 {
2415 if (!e->client->event_count)
2416 _ecore_con_client_free(e->client);
2399 } 2417 }
2400 if (!e->client->event_count)
2401 _ecore_con_client_free(e->client);
2402 } 2418 }
2403 ecore_con_event_client_del_free(e); 2419 ecore_con_event_client_del_free(e);
2404 _ecore_con_event_count--; 2420 _ecore_con_event_count--;
@@ -2412,18 +2428,26 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
2412{ 2428{
2413 if (e->client) 2429 if (e->client)
2414 { 2430 {
2431 Eina_Bool svrfreed = EINA_FALSE;
2432
2415 e->client->event_count = eina_list_remove(e->client->event_count, e); 2433 e->client->event_count = eina_list_remove(e->client->event_count, e);
2416 if (e->client->host_server) 2434 if (e->client->host_server)
2417 { 2435 {
2418 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, e); 2436 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, e);
2419 if ((!svr->event_count) && (svr->delete_me)) 2437 if ((!svr->event_count) && (svr->delete_me))
2420 _ecore_con_server_free(svr); 2438 {
2439 _ecore_con_server_free(svr);
2440 svrfreed = EINA_TRUE;
2441 }
2442 }
2443 if (!svrfreed)
2444 {
2445 if (((!e->client->event_count) && (e->client->delete_me)) ||
2446 ((e->client->host_server &&
2447 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2448 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2449 ecore_con_client_del(e->client);
2421 } 2450 }
2422 if (((!e->client->event_count) && (e->client->delete_me)) ||
2423 ((e->client->host_server &&
2424 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2425 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2426 ecore_con_client_del(e->client);
2427 } 2451 }
2428 ecore_con_event_client_write_free(e); 2452 ecore_con_event_client_write_free(e);
2429 _ecore_con_event_count--; 2453 _ecore_con_event_count--;
@@ -2440,18 +2464,26 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
2440 e = ev; 2464 e = ev;
2441 if (e->client) 2465 if (e->client)
2442 { 2466 {
2467 Eina_Bool svrfreed = EINA_FALSE;
2468
2443 e->client->event_count = eina_list_remove(e->client->event_count, e); 2469 e->client->event_count = eina_list_remove(e->client->event_count, e);
2444 if (e->client->host_server) 2470 if (e->client->host_server)
2445 { 2471 {
2446 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev); 2472 e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev);
2447 } 2473 }
2448 if ((!svr->event_count) && (svr->delete_me)) 2474 if ((!svr->event_count) && (svr->delete_me))
2449 _ecore_con_server_free(svr); 2475 {
2450 if (((!e->client->event_count) && (e->client->delete_me)) || 2476 _ecore_con_server_free(svr);
2451 ((e->client->host_server && 2477 svrfreed = EINA_TRUE;
2452 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || 2478 }
2453 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) 2479 if (!svrfreed)
2454 ecore_con_client_del(e->client); 2480 {
2481 if (((!e->client->event_count) && (e->client->delete_me)) ||
2482 ((e->client->host_server &&
2483 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2484 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2485 ecore_con_client_del(e->client);
2486 }
2455 } 2487 }
2456 free(e->data); 2488 free(e->data);
2457 ecore_con_event_client_data_free(e); 2489 ecore_con_event_client_data_free(e);
@@ -2558,15 +2590,23 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
2558{ 2590{
2559 if (e->client) 2591 if (e->client)
2560 { 2592 {
2593 Eina_Bool svrfreed = EINA_FALSE;
2594
2561 if (eina_list_data_find(svr->clients, e->client)) 2595 if (eina_list_data_find(svr->clients, e->client))
2562 { 2596 {
2563 e->client->event_count = eina_list_remove(e->client->event_count, e); 2597 e->client->event_count = eina_list_remove(e->client->event_count, e);
2564 if ((!e->client->event_count) && (e->client->delete_me)) 2598 if ((!e->client->event_count) && (e->client->delete_me))
2565 _ecore_con_client_free(e->client); 2599 {
2600 _ecore_con_client_free(e->client);
2601 svrfreed = EINA_TRUE;
2602 }
2566 } 2603 }
2567 svr->event_count = eina_list_remove(svr->event_count, e); 2604 svr->event_count = eina_list_remove(svr->event_count, e);
2568 if ((!svr->event_count) && (svr->delete_me)) 2605 if (!svrfreed)
2569 _ecore_con_server_free(svr); 2606 {
2607 if ((!svr->event_count) && (svr->delete_me))
2608 _ecore_con_server_free(svr);
2609 }
2570 } 2610 }
2571 free(e->error); 2611 free(e->error);
2572 ecore_con_event_client_error_free(e); 2612 ecore_con_event_client_error_free(e);