Fix issues detected by static analysis tool 12/57812/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 22 Jan 2016 11:35:12 +0000 (20:35 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 25 Jan 2016 01:37:08 +0000 (10:37 +0900)
Change-Id: I382f0530223d3ec2bbd973f0ca28b854a7e94aa9
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
16 files changed:
binary_xmlresource/file_storage.cpp
binary_xmlresource/layout_bin_parser.cpp
binary_xmlresource/nine_patch_file_list_bin_parser.cpp
scl/gwes/efl/sclgraphics-efl.cpp
scl/gwes/efl/sclwindows-efl.cpp
scl/include/scleventcallback.h
scl/sclcontext.cpp
scl/sclcontroller.cpp
scl/sclerroradjustment.cpp
scl/sclkeyfocushandler.cpp
scl/sclresourcecache.cpp
scl/scluibuilder.cpp
scl/sclutils.cpp
scl/sclwindows.cpp
xml2binary/include/string_encoder.h
xml2binary/xml2dat.cpp

index 26abc19..b7892cb 100644 (file)
@@ -113,7 +113,7 @@ int FileStorage::
         fclose(fp);
         return -1;
     }
-    if (1 != fread(m_storage, size, 1, fp)) {
+    if (size > 0 && 1 != fread(m_storage, size, 1, fp)) {
         if (m_storage) {
             delete []m_storage;
         }
index faf2e35..bb923f4 100644 (file)
@@ -29,6 +29,7 @@ BinLayoutParser::
 BinLayoutParser() {
     m_layout_size = 0;
     memset(m_layout_table, 0x00, sizeof(SclLayout) * MAX_SCL_LAYOUT);
+    parser_info_provider = NULL;
 }
 BinLayoutParser::
 ~BinLayoutParser() {
index ce102d8..530ce13 100644 (file)
@@ -23,6 +23,7 @@
 BinNinePatchFileParser::BinNinePatchFileParser() {
     m_size = 0;
     memset(m_nine_patch_file_list, 0x00, sizeof(SclNinePatchInfo) * MAX_NINE_PATCH_FILE_LIST);
+    parser_info_provider = NULL;
 }
 
 BinNinePatchFileParser::~BinNinePatchFileParser() {
index 4745ff7..bbbb968 100644 (file)
@@ -70,6 +70,8 @@ CSCLGraphicsImplEfl::CSCLGraphicsImplEfl()
 CSCLGraphicsImplEfl::~CSCLGraphicsImplEfl()
 {
     SCL_DEBUG();
+
+    fini ();
 }
 
 void CSCLGraphicsImplEfl::init()
@@ -304,15 +306,17 @@ CSCLGraphicsImplEfl::draw_image(sclwindow window, const scldrawctx draw_ctx, scl
                             evas_object_show(clipper);
 
                             clip_object = new EFLObject;
-                            clip_object->object = clipper;
-                            clip_object->type = EFLOBJECT_CLIPOBJECT;
-                            clip_object->position.x = dest_x;
-                            clip_object->position.y = dest_y;
-                            clip_object->position.width = dest_width;
-                            clip_object->position.height = dest_height;
-                            clip_object->etc_info = image_path;
-                            clip_object->extracted = FALSE;
-                            clip_object->data = NULL;
+                            if (clip_object) {
+                                clip_object->object = clipper;
+                                clip_object->type = EFLOBJECT_CLIPOBJECT;
+                                clip_object->position.x = dest_x;
+                                clip_object->position.y = dest_y;
+                                clip_object->position.width = dest_width;
+                                clip_object->position.height = dest_height;
+                                clip_object->etc_info = image_path;
+                                clip_object->extracted = FALSE;
+                                clip_object->data = NULL;
+                            }
     #endif
                         } else {
                             evas_object_move(image_object, dest_x, dest_y);
index d157346..d43f20e 100644 (file)
@@ -590,9 +590,11 @@ CSCLWindowsImplEfl::show_window(const sclwindow window, sclboolean queue)
         }
 #endif
 
-        utils->log("WinEfl_showwin %p %p (basewin %p mag %p)\n",
-            window,
-            windows->get_base_window(), windows->get_magnifier_window());
+        if (utils) {
+            utils->log("WinEfl_showwin %p %p (basewin %p mag %p)\n",
+                window,
+                windows->get_base_window(), windows->get_magnifier_window());
+        }
     }
 }
 
index 78c9fa7..ca2b2e7 100644 (file)
@@ -43,6 +43,12 @@ struct SclUIEventDesc {
         mouse_farthest_point.x = 0;
         mouse_farthest_point.y = 0;
         event_type = EVENT_TYPE_NONE;
+        mouse_pressed_point.x = 0;
+        mouse_pressed_point.y = 0;
+        mouse_current_point.x = 0;
+        mouse_current_point.y = 0;
+        mouse_farthest_point.x = 0;
+        mouse_farthest_point.y = 0;
     }
     const sclchar *key_value;
     sclulong key_event;
index 6c28833..1396174 100644 (file)
@@ -64,6 +64,9 @@ CSCLContext::reset()
     m_prev_display_mode = DISPLAYMODE_PORTRAIT;
     m_prev_input_mode = NOT_USED;
 
+    m_hidden = false;
+    m_caps_lock_mode = false;
+
     m_magnifier_enabled = TRUE;
     m_sounce_enabled = TRUE;
     m_vibration_enabled = TRUE;
@@ -76,6 +79,8 @@ CSCLContext::reset()
     m_highlight_ui_animation_enabled = FALSE;
 
     m_tts_enabled = FALSE;
+    m_cur_highlighted_key = 0;
+    m_cur_highlighted_window = SCLWINDOW_INVALID;
 
     m_multi_touch_context.clear();
     m_last_touch_device_id = SCLTOUCHDEVICE_INVALID;
index 5d67bd7..b3d5dca 100644 (file)
@@ -3021,7 +3021,7 @@ CSCLController::mouse_move(sclwindow window, sclint x, sclint y, scltouchdevice
                         desc.mouse_farthest_point = context->get_farthest_move_point(touch_id);
                         desc.key_modifier = key_modifier;
 
-                        if (handler->on_event_drag_state_changed(desc) && context->get_magnifier_enabled()) {
+                        if (handler && handler->on_event_drag_state_changed(desc) && context->get_magnifier_enabled()) {
                             update_magnifier = TRUE;
                         }
                     }
@@ -3514,13 +3514,19 @@ CSCLController::timer_event(const scl32 data)
     }
     break;
     case SCL_TIMER_AUTOTEST: {
+        srand(time(NULL));
         sclint rnd = rand() % 100;
 
-        if (cache->get_cur_layout(windows->get_base_window()) == NULL) {
+        const SclLayout *layout = cache->get_cur_layout(windows->get_base_window());
+
+        if (layout == NULL) {
             return FALSE;
         }
-        sclint x = (rand() % (cache->get_cur_layout(windows->get_base_window())->width));
-        sclint y = (rand() % (cache->get_cur_layout(windows->get_base_window())->height));
+        srand(time(NULL));
+        sclint x = (rand() % (layout->width));
+
+        srand(time(NULL));
+        sclint y = (rand() % (layout->height));
 
         if (rnd < 80) {
             events->generate_mouse_event(SCL_MOUSE_EVENT_PRESS, x, y);
@@ -3684,14 +3690,17 @@ void CSCLController::handle_engine_signal(SclInternalSignal signal, sclwindow ta
 
                     if (SCL_EVENT_PASS_ON ==
                         handler->on_event_notification(SCL_UINOTITYPE_SHIFT_STATE_CHANGE, &desc)) {
-                        context->set_shift_state(SCL_SHIFT_STATE_OFF);
+                        if (context)
+                            context->set_shift_state(SCL_SHIFT_STATE_OFF);
                     }
                 }
             }
             break;
             case SIGACTION_UNPRESS_KEYS:
-                context->set_cur_pressed_key(context->get_last_touch_device_id(), NOT_USED);
-                context->set_cur_pressed_window(context->get_last_touch_device_id(), SCLWINDOW_INVALID);
+                if (context) {
+                    context->set_cur_pressed_key(context->get_last_touch_device_id(), NOT_USED);
+                    context->set_cur_pressed_window(context->get_last_touch_device_id(), SCLWINDOW_INVALID);
+                }
             break;
             default:
             break;
index 5b83ada..e046e69 100644 (file)
@@ -64,7 +64,7 @@ CSCLErrorAdjustment::apply_touch_offset(SCLTouchOffsetLevel level, sclint *x, sc
     SclPoint *pos;
     pos = events->get_touch_event_offset();
 
-    if (m_enabled) {
+    if (m_enabled && utils) {
         if (level == TOUCH_OFFSET_LEVEL_1) {
             *x = *x + utils->get_scaled_x(pos->x);
         } else if (level == TOUCH_OFFSET_LEVEL_2) {
index 6f6c87e..c3561d0 100644 (file)
@@ -462,7 +462,7 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
         sclboolean search_in_base_window = TRUE;
         sclboolean exclude_popup_covered_area = FALSE;
 
-        if (!windows->is_base_window(windows->get_nth_window_in_Z_order_list(SCL_WINDOW_Z_TOP))) {
+        if (windows && !windows->is_base_window(windows->get_nth_window_in_Z_order_list(SCL_WINDOW_Z_TOP))) {
             if (cache && window_context && scl_check_arrindex(window_context->inputmode, MAX_SCL_INPUT_MODE)) {
                 const SclLayout *cur_layout =
                     cache->get_cur_layout(windows->get_nth_window_in_Z_order_list(SCL_WINDOW_Z_TOP));
@@ -482,7 +482,7 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
                 windows->get_nth_window_in_Z_order_list(SCL_WINDOW_Z_TOP));
         }
         /* Now search buttons in base window */
-        if (search_in_base_window) {
+        if (search_in_base_window && windows) {
             base_candidate = get_next_candidate_key(direction, cur_key_coordinate, windows->get_base_window());
         }
 
index 62b5164..160684b 100644 (file)
@@ -37,6 +37,11 @@ CSCLResourceCache::CSCLResourceCache()
     SCL_DEBUG();
 
     memset(mCurThemename, 0x00, sizeof(mCurThemename));
+    memset(&mCurBaseLayout, 0x00, sizeof(SclLayout));
+
+    mCurStartingCoordinates.x = 0;
+    mCurStartingCoordinates.y = 0;
+    mCurStartingCoordinatesOption = SCL_STARTING_COORDINATES_OPTION_ALL;
 }
 
 CSCLResourceCache::~CSCLResourceCache()
index da95e1d..51c60fc 100644 (file)
@@ -102,9 +102,12 @@ CSCLUIBuilder::init(sclwindow parent)
             !scl_check_arrindex_unsigned(layout, sclres_manager->get_layout_size())) {
             layout = 0;
         }
-        m_gwes->init(parent,
-                    m_utils->get_scaled_x(sclres_layout[layout].width),
-                    m_utils->get_scaled_y(sclres_layout[layout].height));
+
+        if (m_utils) {
+            m_gwes->init(parent,
+                        m_utils->get_scaled_x(sclres_layout[layout].width),
+                        m_utils->get_scaled_y(sclres_layout[layout].height));
+        }
 
         CSCLContext *context = CSCLContext::get_instance();
         context->set_display_mode(display_mode);
index fd54ac1..e615894 100644 (file)
@@ -75,7 +75,10 @@ CSCLUtils::init()
         scl_assert(default_configure->target_screen_width);
         scl_assert(default_configure->target_screen_height);
         if (default_configure->target_screen_width != 0 &&default_configure->target_screen_height != 0) {
-            impl->get_screen_resolution(&m_scn_resolution_x, &m_scn_resolution_y);
+            CSCLUtilsImpl *impl = GetCSCLUtilsImpl();
+            if (impl)
+                impl->get_screen_resolution(&m_scn_resolution_x, &m_scn_resolution_y);
+
             m_scn_rate_x = m_scn_resolution_x / (float)default_configure->target_screen_width;
             m_scn_rate_y = m_scn_resolution_y / (float)default_configure->target_screen_height;
 
index 801e960..15c2dae 100644 (file)
@@ -263,7 +263,7 @@ sclwindow CSCLWindows::open_popup(const SclWindowOpener opener, const SclRectang
                     button_context->state = BUTTON_STATE_NORMAL;
                 }*/
 
-                if (coordinate)
+                if (windows && coordinate)
                     windows->update_window(window, coordinate->x, coordinate->y, coordinate->width, coordinate->height);
             }
         }
index 40e053e..52fb485 100644 (file)
@@ -27,6 +27,7 @@ const int MAX_NUM_WIDTH = 4;
 class String_Encoder:public IString_Encoder{
     public:
         String_Encoder() {
+            m_file = NULL;
         }
 
         void set_path(const char* file) {
index ba9c546..7c440ca 100644 (file)
@@ -51,22 +51,41 @@ int main(const int argc, char* argv[]) {
         return -1;
     }
 
-    char* xml_text_dir = argv[1];
-    if (0 != access(xml_text_dir, R_OK)) {
-        perror(xml_text_dir);
-        return -1;
+    char* xml_text_dir = NULL;
+    if (argv[1])
+        xml_text_dir = strdup(argv[1]);
+
+    if (xml_text_dir) {
+        if (0 != access(xml_text_dir, R_OK)) {
+            perror(xml_text_dir);
+            free(xml_text_dir);
+            return -1;
+        }
+        else {
+            free(xml_text_dir);
+            xml_text_dir = NULL;
+        }
     }
 
     char* xml_bin_dir = NULL;
     if (argc < 3) {
-        xml_bin_dir = argv[1];
+        if (argv[1])
+            xml_bin_dir = strdup(argv[1]);
     } else {
-        xml_bin_dir = argv[2];
+        if (argv[2])
+            xml_bin_dir = strdup(argv[2]);
     }
 
-    if (0 != access(xml_bin_dir, W_OK)) {
-        perror(xml_bin_dir);
-        return -1;
+    if (xml_bin_dir) {
+        if (0 != access(xml_bin_dir, W_OK)) {
+            perror(xml_bin_dir);
+            free(xml_bin_dir);
+            return -1;
+        }
+        else {
+            free(xml_bin_dir);
+            xml_bin_dir = NULL;
+        }
     }
 
     XMLResource *xmlresource = XMLResource::get_instance();
@@ -75,7 +94,6 @@ int main(const int argc, char* argv[]) {
         return -1;
     }
 
-
     xmlresource->set_resource_directory(xml_text_dir);
     xmlresource->init("main_entry.xml");