From: Nibha Sharma Date: Tue, 26 Mar 2019 04:20:05 +0000 (+0530) Subject: [ITC][iotcon][NonACR][TFDF-1226,heap use after free asan bug fix] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c31845081493f917541f6d0bb903a4844239a231;p=test%2Ftct%2Fnative%2Fapi.git [ITC][iotcon][NonACR][TFDF-1226,heap use after free asan bug fix] Change-Id: I34937e5f7364782653d42ef5df9e20597c1d6829 Signed-off-by: Nibha Sharma --- diff --git a/src/itc/iotcon/ITs-iotcon-presence-response.c b/src/itc/iotcon/ITs-iotcon-presence-response.c index ded7b1410..f2a6635be 100755 --- a/src/itc/iotcon/ITs-iotcon-presence-response.c +++ b/src/itc/iotcon/ITs-iotcon-presence-response.c @@ -114,6 +114,8 @@ static void DestroyResource() static gboolean presence_response_main_loop_quit_idle(gpointer p) { g_main_loop_quit(g_loop); + g_main_loop_unref(g_loop); + g_loop = NULL; return G_SOURCE_REMOVE; } @@ -349,9 +351,12 @@ static int CreateAndFindResource(int tc_index) nRet = iotcon_query_destroy(hQuery); PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_query_destroy", IotConGetError(nRet)); - g_main_loop_run(g_loop); - g_main_loop_unref(g_loop); - g_loop = NULL; + if(g_loop) + { + g_main_loop_run(g_loop); + g_main_loop_unref(g_loop); + g_loop = NULL; + } DestroyResource(); diff --git a/src/itc/iotcon/ITs-iotcon-presence.c b/src/itc/iotcon/ITs-iotcon-presence.c index 5065162d1..139dcc593 100755 --- a/src/itc/iotcon/ITs-iotcon-presence.c +++ b/src/itc/iotcon/ITs-iotcon-presence.c @@ -48,6 +48,8 @@ static gboolean presence_main_loop_quit_idle(gpointer p) { g_main_loop_quit(g_loop); + g_main_loop_unref(g_loop); + g_loop = NULL; return G_SOURCE_REMOVE; } @@ -315,9 +317,12 @@ static int CreateAndFindResource(int tc_index) return 1; } - g_main_loop_run(g_loop); - g_main_loop_unref(g_loop); - g_loop = NULL; + if(g_loop) + { + g_main_loop_run(g_loop); + g_main_loop_unref(g_loop); + g_loop = NULL; + } iotcon_query_destroy(hQuery); presence_destroy_resource(); diff --git a/src/itc/iotcon/ITs-iotcon-request.c b/src/itc/iotcon/ITs-iotcon-request.c index 92d510f80..c3eea8656 100755 --- a/src/itc/iotcon/ITs-iotcon-request.c +++ b/src/itc/iotcon/ITs-iotcon-request.c @@ -60,6 +60,8 @@ static gboolean gmain_loop_quit_idle(gpointer p) { g_main_loop_quit(g_pMainLoop); + g_main_loop_unref(g_pMainLoop); + g_pMainLoop = NULL; return G_SOURCE_REMOVE; } @@ -479,9 +481,13 @@ static int CreateAndFindResource(int tc_index) } nRet = iotcon_query_destroy(hQuery); PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_query_destroy", IotConGetError(nRet)); - - g_main_loop_run(g_pMainLoop); - g_main_loop_unref(g_pMainLoop); + + if(g_pMainLoop) + { + g_main_loop_run(g_pMainLoop); + g_main_loop_unref(g_pMainLoop); + g_pMainLoop = NULL; + } if(g_bRequestHandlerCB != true) { diff --git a/src/itc/iotcon/ITs-iotcon-resource.c b/src/itc/iotcon/ITs-iotcon-resource.c index e238f36df..391e601e5 100755 --- a/src/itc/iotcon/ITs-iotcon-resource.c +++ b/src/itc/iotcon/ITs-iotcon-resource.c @@ -477,6 +477,8 @@ static gboolean gmain_loop_quit_idle(gpointer p) { g_main_loop_quit(g_pMainLoop); + g_main_loop_unref(g_pMainLoop); + g_pMainLoop = NULL; return G_SOURCE_REMOVE; } @@ -855,9 +857,13 @@ static int CreateAndFindResource(int tc_index) } nRet = iotcon_query_destroy(hQuery); PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_query_destroy", IotConGetError(nRet)); - - g_main_loop_run(g_pMainLoop); - g_main_loop_unref(g_pMainLoop); + + if(g_pMainLoop) + { + g_main_loop_run(g_pMainLoop); + g_main_loop_unref(g_pMainLoop); + g_pMainLoop = NULL; + } if(g_bRequestHandlerCB != true) { diff --git a/src/itc/iotcon/ITs-iotcon-response.c b/src/itc/iotcon/ITs-iotcon-response.c index a4e8b54dd..ab85ec7e6 100755 --- a/src/itc/iotcon/ITs-iotcon-response.c +++ b/src/itc/iotcon/ITs-iotcon-response.c @@ -40,6 +40,8 @@ static int g_timeout_count; static gboolean gmain_loop_quit_idle(gpointer p) { g_main_loop_quit(g_loop); + g_main_loop_unref(g_loop); + g_loop = NULL; return G_SOURCE_REMOVE; } /** @@ -258,8 +260,12 @@ static int CreateAndFindResource() nRet = iotcon_query_destroy(hQuery); PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_query_destroy", IotConGetError(nRet)); - g_main_loop_run(g_loop); - g_main_loop_unref(g_loop); + if(g_loop) + { + g_main_loop_run(g_loop); + g_main_loop_unref(g_loop); + g_loop = NULL; + } if(g_bRequestRespHandlerCB != true) {