Fix memory corruption on watchface change 21/105321/1 accepted/tizen/3.0/common/20161219.113522 accepted/tizen/3.0/wearable/20161219.095510 submit/tizen_3.0/20161216.082724
authorDaehyeon Jung <darrenh.jung@samsung.com>
Fri, 16 Dec 2016 08:13:37 +0000 (17:13 +0900)
committerDaehyeon Jung <darrenh.jung@samsung.com>
Fri, 16 Dec 2016 08:14:27 +0000 (17:14 +0900)
Change-Id: I06a0776c03c2fa175d9b194259c170b37585685c
Signed-off-by: Daehyeon Jung <darrenh.jung@samsung.com>
src/aul_rsm.c

index e48711d..ebf849e 100644 (file)
@@ -341,6 +341,10 @@ API int aul_rsm_viewer_unset_surface_handler(const char *id)
                return -1;
        }
        g_hash_table_remove(__viewer_tbl, id);
+
+       if (surface->id)
+               free(surface->id);
+
        free(surface);
 
        return 0;
@@ -363,7 +367,13 @@ API int aul_rsm_viewer_set_surface_handler(const char *id, aul_rsm_handler *cbs,
                }
        }
 
-       surface = (struct __surface_s *)malloc(sizeof(struct __surface_s));
+       surface = g_hash_table_lookup(__viewer_tbl, id);
+       if (surface) {
+               _E("%s handler is already exist");
+               return -1;
+       }
+
+       surface = (struct __surface_s *)calloc(1, sizeof(struct __surface_s));
        if (!surface) {
                _E("out of memory");
                return -1;