Remove double free situation 81/297981/1
authorjinbong, Lee <jinbong.lee@samsung.com>
Tue, 29 Aug 2023 10:56:54 +0000 (19:56 +0900)
committerjinbong, Lee <jinbong.lee@samsung.com>
Tue, 29 Aug 2023 10:56:54 +0000 (19:56 +0900)
 - if (source->fd_type == FD_TYPE_FENCE && source->type == SOURCE_TYPE_DISPOSABLE)
   then g_source_remove_unix_fd, g_source_destroy, g_source_unref is called twice for source->gsource.
 - it can cause error like that free already freed memory or free with invalid pointer (garbage value)

Change-Id: I44e3b1d50b0710d9cd2ddcf8e8c8f4215acff344

src/tpl_utils_gthread.c

index e9f506b..b4b78cf 100644 (file)
@@ -365,7 +365,8 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread)
                        g_source_destroy(&source->gsource);
                        g_source_unref(&source->gsource);
                }
-               __gsource_remove_and_destroy(source);
+               else
+                       __gsource_remove_and_destroy(source);
        }
 
        g_mutex_unlock(&thread->thread_mutex);