[ITC][iotcon][NonACR][TFDF-1226,heap use after free asan bug fix] 96/202196/2
authorNibha Sharma <nibha.sharma@samsung.com>
Tue, 26 Mar 2019 04:20:05 +0000 (09:50 +0530)
committermanoj gupta <manoj.g2@samsung.com>
Mon, 8 Apr 2019 10:54:09 +0000 (10:54 +0000)
Change-Id: I34937e5f7364782653d42ef5df9e20597c1d6829
Signed-off-by: Nibha Sharma <nibha.sharma@samsung.com>
src/itc/iotcon/ITs-iotcon-presence-response.c
src/itc/iotcon/ITs-iotcon-presence.c
src/itc/iotcon/ITs-iotcon-request.c
src/itc/iotcon/ITs-iotcon-resource.c
src/itc/iotcon/ITs-iotcon-response.c

index ded7b1410c8956b214cde4fc882015745ad25c57..f2a6635be4cd77a7dab6e5be97234606b1bcc053 100755 (executable)
@@ -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();
 
index 5065162d13002641d4ff2d51fc6dba0aefb8cbc8..139dcc5939489a084bbcc1449aec3f47e8d9dde2 100755 (executable)
@@ -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();
index 92d510f801b6cc62a61d53e892d1f32e7ae1108d..c3eea8656c1f35a721638f5f2d7485c64fcdc8ab 100755 (executable)
@@ -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)
        {
index e238f36df1978bb922c87d7e32232b3997de45be..391e601e5333c2db223ccff08c8f6c403aa0dc64 100755 (executable)
@@ -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)
        {
index a4e8b54dd20924741fc92682525b936ad570488d..ab85ec7e6443f1dc852d7b4fe0ab66c9408ba582 100755 (executable)
@@ -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)
        {