From b835b14540683007e17bad9768860a44a160c016 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 22 Jan 2016 20:35:12 +0900 Subject: [PATCH] Fix issues detected by static analysis tool Change-Id: I382f0530223d3ec2bbd973f0ca28b854a7e94aa9 Signed-off-by: Jihoon Kim --- binary_xmlresource/file_storage.cpp | 2 +- binary_xmlresource/layout_bin_parser.cpp | 1 + .../nine_patch_file_list_bin_parser.cpp | 1 + scl/gwes/efl/sclgraphics-efl.cpp | 22 ++++++++----- scl/gwes/efl/sclwindows-efl.cpp | 8 +++-- scl/include/scleventcallback.h | 6 ++++ scl/sclcontext.cpp | 5 +++ scl/sclcontroller.cpp | 23 +++++++++---- scl/sclerroradjustment.cpp | 2 +- scl/sclkeyfocushandler.cpp | 4 +-- scl/sclresourcecache.cpp | 5 +++ scl/scluibuilder.cpp | 9 +++-- scl/sclutils.cpp | 5 ++- scl/sclwindows.cpp | 2 +- xml2binary/include/string_encoder.h | 1 + xml2binary/xml2dat.cpp | 38 ++++++++++++++++------ 16 files changed, 96 insertions(+), 38 deletions(-) diff --git a/binary_xmlresource/file_storage.cpp b/binary_xmlresource/file_storage.cpp index 26abc19..b7892cb 100644 --- a/binary_xmlresource/file_storage.cpp +++ b/binary_xmlresource/file_storage.cpp @@ -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; } diff --git a/binary_xmlresource/layout_bin_parser.cpp b/binary_xmlresource/layout_bin_parser.cpp index faf2e35..bb923f4 100644 --- a/binary_xmlresource/layout_bin_parser.cpp +++ b/binary_xmlresource/layout_bin_parser.cpp @@ -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() { diff --git a/binary_xmlresource/nine_patch_file_list_bin_parser.cpp b/binary_xmlresource/nine_patch_file_list_bin_parser.cpp index ce102d8..530ce13 100644 --- a/binary_xmlresource/nine_patch_file_list_bin_parser.cpp +++ b/binary_xmlresource/nine_patch_file_list_bin_parser.cpp @@ -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() { diff --git a/scl/gwes/efl/sclgraphics-efl.cpp b/scl/gwes/efl/sclgraphics-efl.cpp index 4745ff7..bbbb968 100644 --- a/scl/gwes/efl/sclgraphics-efl.cpp +++ b/scl/gwes/efl/sclgraphics-efl.cpp @@ -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); diff --git a/scl/gwes/efl/sclwindows-efl.cpp b/scl/gwes/efl/sclwindows-efl.cpp index d157346..d43f20e 100644 --- a/scl/gwes/efl/sclwindows-efl.cpp +++ b/scl/gwes/efl/sclwindows-efl.cpp @@ -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()); + } } } diff --git a/scl/include/scleventcallback.h b/scl/include/scleventcallback.h index 78c9fa7..ca2b2e7 100644 --- a/scl/include/scleventcallback.h +++ b/scl/include/scleventcallback.h @@ -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; diff --git a/scl/sclcontext.cpp b/scl/sclcontext.cpp index 6c28833..1396174 100644 --- a/scl/sclcontext.cpp +++ b/scl/sclcontext.cpp @@ -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; diff --git a/scl/sclcontroller.cpp b/scl/sclcontroller.cpp index 5d67bd7..b3d5dca 100644 --- a/scl/sclcontroller.cpp +++ b/scl/sclcontroller.cpp @@ -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; diff --git a/scl/sclerroradjustment.cpp b/scl/sclerroradjustment.cpp index 5b83ada..e046e69 100644 --- a/scl/sclerroradjustment.cpp +++ b/scl/sclerroradjustment.cpp @@ -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) { diff --git a/scl/sclkeyfocushandler.cpp b/scl/sclkeyfocushandler.cpp index 6f6c87e..c3561d0 100644 --- a/scl/sclkeyfocushandler.cpp +++ b/scl/sclkeyfocushandler.cpp @@ -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()); } diff --git a/scl/sclresourcecache.cpp b/scl/sclresourcecache.cpp index 62b5164..160684b 100644 --- a/scl/sclresourcecache.cpp +++ b/scl/sclresourcecache.cpp @@ -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() diff --git a/scl/scluibuilder.cpp b/scl/scluibuilder.cpp index da95e1d..51c60fc 100644 --- a/scl/scluibuilder.cpp +++ b/scl/scluibuilder.cpp @@ -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); diff --git a/scl/sclutils.cpp b/scl/sclutils.cpp index fd54ac1..e615894 100644 --- a/scl/sclutils.cpp +++ b/scl/sclutils.cpp @@ -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; diff --git a/scl/sclwindows.cpp b/scl/sclwindows.cpp index 801e960..15c2dae 100644 --- a/scl/sclwindows.cpp +++ b/scl/sclwindows.cpp @@ -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); } } diff --git a/xml2binary/include/string_encoder.h b/xml2binary/include/string_encoder.h index 40e053e..52fb485 100644 --- a/xml2binary/include/string_encoder.h +++ b/xml2binary/include/string_encoder.h @@ -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) { diff --git a/xml2binary/xml2dat.cpp b/xml2binary/xml2dat.cpp index ba9c546..7c440ca 100644 --- a/xml2binary/xml2dat.cpp +++ b/xml2binary/xml2dat.cpp @@ -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"); -- 2.7.4