Fix issues detected by static analysis tool 37/74937/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 16 Jun 2016 04:24:06 +0000 (13:24 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 16 Jun 2016 04:24:06 +0000 (13:24 +0900)
Change-Id: I06600073df4d6e749bbc476543128ae38e439705

scl/gwes/efl/sclevents-efl.cpp
scl/sclkeyfocushandler.cpp
scl/sclresourcecache.cpp
scl/scluibuilder.cpp
scl/sclwindows.cpp
xmlresource/layout_parser.cpp

index 4448537..ea85acd 100644 (file)
@@ -179,17 +179,26 @@ static void gesture_cb(void *data, const Eldbus_Message *msg)
     int g_type;
     static int last_pos_x = -1;
     static int last_pos_y = -1;
+
     if (!msg) {
         LOGD("Incoming message is empty");
         return;
     }
     CSCLController *controller = CSCLController::get_instance();
     CSCLWindows *windows = CSCLWindows::get_instance();
+
     if (!windows || !controller) return;
+
     sclwindow base_window = windows->get_base_window();
     SclWindowContext *window_context = windows->get_window_context(base_window);
-    if (window_context && window_context->hidden) return;
-    LOGD("window_context->geometry.x=%d y=%d w=%d h=%d",window_context->geometry.x, window_context->geometry.y, window_context->geometry.width, window_context->geometry.height);
+
+    if (!window_context) return;
+    if (window_context->hidden) return;
+
+    LOGD("window_context->geometry.x=%d y=%d w=%d h=%d",
+            window_context->geometry.x, window_context->geometry.y,
+            window_context->geometry.width, window_context->geometry.height);
+
     Gesture_Info *info = (Gesture_Info *)calloc(sizeof(Gesture_Info), 1);
     if (!eldbus_message_arguments_get(msg, "iiiiiiu", &g_type, &info->x_beg,
                                       &info->y_beg, &info->x_end, &info->y_end,
@@ -198,9 +207,11 @@ static void gesture_cb(void *data, const Eldbus_Message *msg)
         free(info);
         return;
     }
+
     info->type = (Gesture)g_type;
     LOGD("Incoming gesture name is %d : %d %d %d %d %d", info->type,
          info->x_beg, info->y_beg, info->x_end, info->y_end, info->state);
+
     if (info->type == ONE_FINGER_HOVER || info->type == ONE_FINGER_SINGLE_TAP) {
         if (info->y_beg >= window_context->geometry.y) {
             last_pos_x = info->x_beg;
@@ -208,8 +219,7 @@ static void gesture_cb(void *data, const Eldbus_Message *msg)
             LOGD("hover last_pos_x=%d last_pos_y=%d", last_pos_x, last_pos_y);
             controller->mouse_over(base_window, last_pos_x, last_pos_y);
         }
-    }
-    else if (info->type == ONE_FINGER_DOUBLE_TAP) {
+    } else if (info->type == ONE_FINGER_DOUBLE_TAP) {
         if (info->y_beg >= window_context->geometry.y) {
             last_pos_x = info->x_beg;
             last_pos_y = info->y_beg - window_context->geometry.y;
index 032efed..b0c2d3d 100644 (file)
@@ -508,13 +508,17 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
             sclshort base_layout = context->get_base_layout();
             sclshort popup_layout = context->get_popup_layout(popup_window);
 
-            SclLayoutKeyCoordinatePointer base_key =
-                sclres_layout_key_coordinate_pointer_frame[base_layout][base_candidate.candidate];
-            SclLayoutKeyCoordinatePointer popup_key =
-                sclres_layout_key_coordinate_pointer_frame[popup_layout][popup_candidate.candidate];
-
-            SclWindowContext *base_window_context = windows->get_window_context(windows->get_base_window());
-            SclWindowContext *popup_window_context = windows->get_window_context(popup_window);
+            SclLayoutKeyCoordinatePointer base_key = NULL;
+            SclLayoutKeyCoordinatePointer popup_key = NULL;
+            SclWindowContext *base_window_context = NULL;
+            SclWindowContext *popup_window_context = NULL;
+
+            if (scl_check_arrindex(base_layout, MAX_SCL_LAYOUT) && scl_check_arrindex(popup_layout, MAX_SCL_LAYOUT)) {
+                base_key = sclres_layout_key_coordinate_pointer_frame[base_layout][base_candidate.candidate];
+                popup_key = sclres_layout_key_coordinate_pointer_frame[popup_layout][popup_candidate.candidate];
+                base_window_context = windows->get_window_context(windows->get_base_window());
+                popup_window_context = windows->get_window_context(popup_window);
+            }
 
             SclRectangle base_key_coordinate = {0, 0, 0, 0};
             if (base_window_context) {
index af31444..9555831 100644 (file)
@@ -802,6 +802,8 @@ CSCLResourceCache::remove_private_key(sclint id)
     sclint loop;
     CSCLContext *context = CSCLContext::get_instance();
 
+    if (!context) return;
+
     /* resets the current properties to predefined properties */
     sclshort layout =  context->get_base_layout();
 
index e920516..b010827 100644 (file)
@@ -849,9 +849,12 @@ CSCLUIBuilder::draw_button_bg_by_layoutimg(const sclwindow window, const scldraw
 
     CSCLContext *context = CSCLContext::get_instance();
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
+    SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+
+    if (!context || !cache || !sclres_manager) return FALSE;
+
     const SclLayout* layout = cache->get_cur_layout(window);
     const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
-    SclResParserManager *sclres_manager = SclResParserManager::get_instance();
     PSclModifierDecoration sclres_modifier_decoration = sclres_manager->get_modifier_decoration_table();
     assert(sclres_modifier_decoration != NULL);
 
index 15c2dae..4a94923 100644 (file)
@@ -868,12 +868,12 @@ void CSCLWindows::set_window_rotation(const sclwindow window, SCLRotation rotati
     SCL_DEBUG();
 
     CSCLWindowsImpl* impl = get_scl_windows_impl();
+    CSCLUtils *utils = CSCLUtils::get_instance();
 
-    if (impl) {
+    if (impl && utils) {
         if (window == NULL) {
             impl->set_window_rotation(m_base_window_context.window, rotation);
             if (SCLWINDOW_INVALID != m_magnifier_window_context.window) {
-                CSCLUtils *utils = CSCLUtils::get_instance();
 
                 SclResParserManager *sclres_manager = SclResParserManager::get_instance();
                 PSclMagnifierWndConfigure magnifier_configure = NULL;
index a39257b..d1e98ca 100644 (file)
@@ -968,20 +968,22 @@ LayoutParserImpl::parsing_label_record_node(
                 for (int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
                     if ((shift_state == shift_loop || shift_state == -1)) {
                         xmlChar* key = xmlNodeGetContent(child_node);
-                        cur_rec->label[shift_loop][label_for_one_state] = (sclchar*)key;
-                        if (auto_upper) {
-                            if (xmlStrlen(key) == 1 && shift_loop != SCL_SHIFT_STATE_OFF) {
-                                /* Let's manipulate the string for auto_upper */
-                                *key = toupper(*(cur_rec->label[SCL_SHIFT_STATE_OFF][label_for_one_state]));
+                        if (key) {
+                            cur_rec->label[shift_loop][label_for_one_state] = (sclchar*)key;
+                            if (auto_upper) {
+                                if (xmlStrlen(key) == 1 && shift_loop != SCL_SHIFT_STATE_OFF) {
+                                    /* Let's manipulate the string for auto_upper */
+                                    *key = toupper(*(cur_rec->label[SCL_SHIFT_STATE_OFF][label_for_one_state]));
+                                }
                             }
-                        }
-                        /* If current key_value is NULL, let's just consider this label is the default key_value */
-                        if (label_for_one_state == 0) {
-                            if (cur_rec->key_value[shift_loop][label_for_one_state] == NULL) {
-                                cur_rec->key_value[shift_loop][label_for_one_state] = (sclchar*)key;
+                            /* If current key_value is NULL, let's just consider this label is the default key_value */
+                            if (label_for_one_state == 0) {
+                                if (cur_rec->key_value[shift_loop][label_for_one_state] == NULL) {
+                                    cur_rec->key_value[shift_loop][label_for_one_state] = (sclchar*)key;
+                                }
                             }
+                            add_key_string(key);
                         }
-                        add_key_string(key);
                     }
                 }
             }
@@ -1010,8 +1012,10 @@ LayoutParserImpl::parsing_magnifier_label_record_node(
                 for (int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
                     if ((shift_state == shift_loop || shift_state == -1)) {
                         xmlChar* key = xmlNodeGetContent(child_node);
-                        cur_rec->magnifier_label[shift_loop][label_for_one_state] = (sclchar*)key;
-                        add_key_string(key);
+                        if (key) {
+                            cur_rec->magnifier_label[shift_loop][label_for_one_state] = (sclchar*)key;
+                            add_key_string(key);
+                        }
                     }
                 }
             }
@@ -1039,8 +1043,10 @@ LayoutParserImpl::parsing_hint_string_record_node(
                     for (int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
                         if ((shift_state == shift_loop || shift_state == -1)) {
                             xmlChar* key = xmlNodeGetContent(child_node);
-                            cur_rec->hint_string[shift_loop][multichar_state] = (sclchar*)key;
-                            add_key_string(key);
+                            if (key) {
+                                cur_rec->hint_string[shift_loop][multichar_state] = (sclchar*)key;
+                                add_key_string(key);
+                            }
                         }
                     }
                 }
@@ -1067,8 +1073,10 @@ LayoutParserImpl::parsing_label_image_record_node(
                     if ((shift_state == shift_loop || shift_state == -1) &&
                         (button_state == button_loop || button_state == -1)) {
                             xmlChar* key = xmlNodeGetContent(child_node);
-                            cur_rec->image_label_path[shift_loop][button_loop] = (sclchar*)key;
-                            add_key_string(key);
+                            if (key) {
+                                cur_rec->image_label_path[shift_loop][button_loop] = (sclchar*)key;
+                                add_key_string(key);
+                            }
                     }
                 }
             }
@@ -1095,8 +1103,10 @@ LayoutParserImpl::parsing_background_image_record_node(
                     if ((shift_state == shift_loop || shift_state == -1) &&
                         (button_state == button_loop || button_state == -1)) {
                             xmlChar* key = xmlNodeGetContent(child_node);
-                            cur_rec->bg_image_path[shift_loop][button_loop] = (sclchar*)key;
-                            add_key_string(key);
+                            if (key) {
+                                cur_rec->bg_image_path[shift_loop][button_loop] = (sclchar*)key;
+                                add_key_string(key);
+                            }
                     }
                 }
             }