From: Suyeon Hwang Date: Mon, 6 Nov 2017 06:49:50 +0000 (+0900) Subject: Add null check about javascript result X-Git-Tag: accepted/tizen/unified/20180307.071344~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F57%2F158957%2F1;p=platform%2Fcore%2Fuifw%2Fvc-webview.git Add null check about javascript result Change-Id: Ic0cc1f883526f0a62dc01279313aac36b67540bb Signed-off-by: Suyeon Hwang --- diff --git a/src/voice_control_webview.cpp b/src/voice_control_webview.cpp index ff88941..0f3c2ec 100755 --- a/src/voice_control_webview.cpp +++ b/src/voice_control_webview.cpp @@ -155,8 +155,8 @@ char* VCWebView::vc_webview_load_script(const char* filename) LOGI("==== Load Script ===="); FILE *f = NULL; - char js_path[1024] = {'\0',}; - char buf[256] = {'\0',}; + char js_path[1024] = {'\0'}; + char buf[256] = {'\0'}; snprintf(js_path, 1024, "%s/%s", VC_WEBVIEW_JS_PATH, filename); LOGD("===path (%s)", js_path); @@ -174,7 +174,7 @@ char* VCWebView::vc_webview_load_script(const char* filename) } fseek(f, 0, SEEK_SET); - char *script = new char [fsize + 1]; + char *script = new char[fsize + 1]; long int ret = fread(script, 1, fsize, f); if (ret != fsize) { LOGE("Couldn't read vc-webview.js file %d, %d", fsize, ret); @@ -201,9 +201,9 @@ void VCWebView::__vc_webview_init() { LOGI("%d ", vc_widget_set_send_current_command_list_cb(g_vc_w, __vc_widget_send_current_command_list_cb, (void*)m_list)); LOGI("%d ", vc_widget_set_current_language_changed_cb(g_vc_w, __vc_language_changed_cb, NULL)); #if 0 - LOGI("%d ",vc_widget_set_request_action_cb(g_vc_w, __vc_request_action_cb, NULL)); - LOGI("%d ",vc_widget_set_getdata_cb(g_vc_w, __vc_get_client_data_cb, NULL)); - LOGI("%d ",vc_widget_set_setdata_cb(g_vc_w, __vc_set_client_data_cb, NULL)); + LOGI("%d ", vc_widget_set_request_action_cb(g_vc_w, __vc_request_action_cb, NULL)); + LOGI("%d ", vc_widget_set_getdata_cb(g_vc_w, __vc_get_client_data_cb, NULL)); + LOGI("%d ", vc_widget_set_setdata_cb(g_vc_w, __vc_set_client_data_cb, NULL)); #endif LOGI("%d ", vc_widget_prepare(g_vc_w)); @@ -220,7 +220,7 @@ void VCWebView::__vc_webview_init() { // Load language script - char filename[64] = {'\0',}; + char filename[64] = {'\0'}; char *current = NULL; if (0 != vc_widget_get_current_language(g_vc_w, ¤t)) { LOGW("[WARN] Fail to get current langauge"); @@ -571,7 +571,7 @@ void VCWebView::vc_language_changed_cb(const char* previous, const char* current if (NULL != m_lang_script) delete [] m_lang_script; - char filename[64] = {'\0',}; + char filename[64] = {'\0'}; snprintf(filename, 64, "vc-webview-%s.js", current); m_lang_script = vc_webview_load_script(filename); if (NULL == m_lang_script) { @@ -591,7 +591,7 @@ void VCWebView::vc_state_changed_cb(vc_state_e previous, vc_state_e current, voi char* lang = NULL; vc_widget_get_current_language(g_vc_w, &lang); if (NULL != lang) { - char filename[64] = {'\0',}; + char filename[64] = {'\0'}; snprintf(filename, 64, "vc-webview-%s.js", lang); if (NULL != m_lang_script) delete [] m_lang_script; @@ -796,8 +796,8 @@ static void __js_get_script_name_cb(Evas_Object *obj, const char *javascript_res FILE *f = NULL; file_name = host_name + path_name + ".js"; - char js_path[1024] = {'\0',}; - char buf[256] = {'\0',}; + char js_path[1024] = {'\0'}; + char buf[256] = {'\0'}; snprintf(js_path, 1024, "%s/%s", VC_WEBVIEW_CUSTOM_PATH, file_name.c_str()); LOGD("=== path (%s)", js_path); @@ -829,7 +829,7 @@ static void __js_get_script_name_cb(Evas_Object *obj, const char *javascript_res } fseek(f, 0, SEEK_SET); - char *script = new char [fsize + 1]; + char *script = new char[fsize + 1]; long int ret = fread(script, 1, fsize, f); if (ret != fsize) { LOGE("Couldn't read vc-webview.js file %d, %d", fsize, ret); @@ -891,7 +891,12 @@ static void __js_get_conflict_status_cb(Evas_Object *obj, const char *javascript int *conflict = (int*)data; - *conflict = atoi(javascript_result); + if (NULL != javascript_result) { + *conflict = atoi(javascript_result); + } else { + LOGE("Invalid javascript action"); + *conflict = -1; + } g_wait = false; }