Fix ASAN issue (heap-use-after-free) 27/216127/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Mon, 21 Oct 2019 08:34:26 +0000 (17:34 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Mon, 21 Oct 2019 08:34:52 +0000 (17:34 +0900)
Change-Id: I9f3112cb745ecc592e3faa158f26ec23226ffd92
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/vc_widget_client.c

index 27ee57d569621842454ac0e9679275208e5fad7e..5c13f163ce8b3df0e354c779c50027c5863f8b1b 100644 (file)
@@ -31,13 +31,14 @@ static pthread_mutex_t g_widget_list_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 vc_widget_s* widget_get(vc_h vc)
 {
+       pthread_mutex_lock(&g_widget_list_mutex);
+
        if (vc == NULL) {
                SLOG(LOG_WARN, TAG_VCW, "[WARNING] Input parameter is NULL");
+               pthread_mutex_unlock(&g_widget_list_mutex);
                return NULL;
        }
 
-       pthread_mutex_lock(&g_widget_list_mutex);
-
        vc_widget_s *data = NULL;
 
        int count = g_slist_length(g_widget_list);
@@ -46,7 +47,7 @@ vc_widget_s* widget_get(vc_h vc)
        for (i = 0; i < count; i++) {
                data = g_slist_nth_data(g_widget_list, i);
 
-               if (NULL != data) {
+               if (NULL != data && NULL != data->vc) {
                        if (vc->handle == data->vc->handle) {
                                pthread_mutex_unlock(&g_widget_list_mutex);
                                return data;