avoid dereference null, fix memory leak
[platform/core/uifw/libtdm.git] / src / tdm.c
index 8c7843a..3f6388c 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -756,7 +756,7 @@ _tdm_display_load_module_with_file(tdm_private_display *private_display,
        private_display->bdata = module_data->init((tdm_display *)private_display, &ret);
        TDM_TRACE_END();
        if (ret != TDM_ERROR_NONE) {
-               TDM_ERR("'%s' init failed", file);
+               TDM_ERR("failed to init '%s' module", module_data->name);
                goto failed_load;
        }
 
@@ -767,7 +767,7 @@ _tdm_display_load_module_with_file(tdm_private_display *private_display,
                goto failed_load;
        }
 
-       TDM_INFO("Success to load module(%s)", file);
+       TDM_INFO("Success to load '%s' module", module_data->name);
 
        return TDM_ERROR_NONE;
 failed_load:
@@ -966,6 +966,11 @@ tdm_display_deinit(tdm_display *dpy)
        free(private_display);
        g_private_display = NULL;
 
+       if (tdm_debug_dump_dir) {
+               free(tdm_debug_dump_dir);
+               tdm_debug_dump_dir = NULL;
+       }
+
        _pthread_mutex_unlock(&gLock);
 
        TDM_INFO("done");
@@ -1047,6 +1052,7 @@ tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_s
 
        snprintf(temp, sizeof(temp), "%s", dump_str);
        arg = strtok_r(temp, ",", &end);
+       TDM_GOTO_IF_FAIL(arg != NULL, done);
 
        if (!strncmp(arg, "none", 4)) {
                tdm_debug_dump = 0;