Fix invalid result 97/117797/1
authorKwangyoun Kim <ky85.kim@samsung.com>
Tue, 24 Jan 2017 13:49:56 +0000 (22:49 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 7 Mar 2017 11:56:54 +0000 (03:56 -0800)
Change-Id: I51cac04fe9e87c8b3e5fd9db73da3ada52660ef8
(cherry picked from commit 12fef272e3d75441860b0fd41c0607a747919506)

client/vc_mgr_client.c
common/vc_info_parser.c
server/vcd_server.c

index 234d0d9..b3cf80d 100644 (file)
@@ -798,8 +798,11 @@ int vc_mgr_client_set_all_result(vc_h vc, int event, const char* result_text)
 
        if (NULL != client->all_result_text) {
                free(client->all_result_text);
+               client->all_result_text = NULL;
+       }
+       if (NULL != result_text) {
+               client->all_result_text = strdup(result_text);
        }
-       client->all_result_text = strdup(result_text);
 
        return 0;
 }
index f46f80a..da0ab55 100644 (file)
@@ -286,11 +286,24 @@ int vc_info_parser_set_demandable_client(const char* filepath)
 
 int vc_info_parser_set_result(const char* result_text, int event, const char* msg, vc_cmd_list_h vc_cmd_list, bool exclusive)
 {
-       int ret = vc_db_insert_result(result_text, event, msg, vc_cmd_list, exclusive);
+       char* temp_text = NULL;
+       if (NULL == result_text) {
+               temp_text = strdup("#NULL");
+       } else {
+               temp_text = strdup(result_text);
+       }
+
+       int ret = vc_db_insert_result(temp_text, event, msg, vc_cmd_list, exclusive);
        if (0 != ret) {
                SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Insert db is failed, ret = %d", ret);
        }
        SLOG(LOG_DEBUG, vc_info_tag(), "[Success] Save result command file");
+
+       if (NULL != temp_text) {
+               free(temp_text);
+               temp_text = NULL;
+       }
+
        return ret;
 }
 
@@ -301,10 +314,23 @@ int vc_info_parser_get_result(char** result_text, int* event, char** result_mess
                return -1;
        }
 
-       int ret = vc_db_get_result(result_text, event, result_message, pid, vc_cmd_list, exclusive);
+       char* temp_text = NULL;
+       int ret = vc_db_get_result(&temp_text, event, result_message, pid, vc_cmd_list, exclusive);
        if (0 != ret) {
                SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Insert db is failed, ret = %d", ret);
        }
+
+       if (!strcmp(temp_text, "#NULL")) {
+               *result_text = NULL;
+       } else {
+               *result_text = strdup(temp_text);
+       }
+
+       if (NULL != temp_text) {
+               free(temp_text);
+               temp_text = NULL;
+       }
+
        return ret;
 }
 
@@ -670,4 +696,4 @@ int __vc_cmd_parser_print_commands(GSList* cmd_list)
        }
 
        return 0;
-}
\ No newline at end of file
+}
index 00f5792..c8b4169 100755 (executable)
@@ -641,9 +641,11 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
                /* No result */
                if (NULL != all_result) {
                        SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result);
-                       bool temp = vcd_client_manager_get_exclusive();
-                       vc_info_parser_set_result(all_result, event, msg, NULL, temp);
+               } else {
+                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is NULL");
                }
+               bool temp = vcd_client_manager_get_exclusive();
+               vc_info_parser_set_result(all_result, event, msg, NULL, temp);
 
                int pid = vcd_client_widget_get_foreground_pid();
                if (-1 != pid) {