Fix prevent alarms
authorWonYoung Choi <wy80.choi@samsung.com>
Mon, 21 Dec 2015 10:51:53 +0000 (19:51 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Mon, 21 Dec 2015 10:52:23 +0000 (19:52 +0900)
null-checkers and initializers are added to fix alarms by prevent

common/app_control.cc
common/resource_manager.cc
extensions/renderer/widget_module.cc
runtime/browser/popup.cc
runtime/browser/splash_screen.cc
runtime/browser/web_view_impl.cc

index d74f436..d625056 100644 (file)
@@ -194,10 +194,11 @@ std::vector<std::string> AppControl::data_array(const std::string& key) const {
   const char** data_array = appsvc_get_data_array(app_control_bundle_,
                                                   key.c_str(), &data_array_len);
   std::vector<std::string> data_vector;
-
-  if (data_array_len > 0) {
-    for (int i = 0; i < data_array_len; i++) {
-      data_vector.push_back(data_array[i]);
+  if (data_array) {  // checking whether the 'data_array' is valid
+    if (data_array_len > 0) {
+      for (int i = 0; i < data_array_len; i++) {
+        data_vector.push_back(data_array[i]);
+      }
     }
   }
   return data_vector;
index 74e95a4..6550efb 100644 (file)
@@ -182,7 +182,9 @@ bool ResourceManager::Resource::operator==(const Resource& res) {
 
 ResourceManager::ResourceManager(ApplicationData* application_data,
                                  LocaleManager* locale_manager)
-    : application_data_(application_data), locale_manager_(locale_manager) {
+    : application_data_(application_data),
+      locale_manager_(locale_manager),
+      security_model_version_(0) {
   if (application_data != NULL) {
     appid_ = application_data->tizen_application_info()->id();
     if (application_data->csp_info() != NULL ||
@@ -200,16 +202,20 @@ ResourceManager::GetDefaultResource() {
   std::string src;
   std::string type;
   std::string encoding = kDefaultEncoding;
-  auto content_info = application_data_->content_info();
-  if (content_info) {
-    src = content_info->src();
-    type = content_info->type();
-    encoding = content_info->encoding();
-    LOGGER(DEBUG) << "src: " << src;
-    LOGGER(DEBUG) << "type: " << type;
-    LOGGER(DEBUG) << "encoding: " << encoding;
-  } else {
-    LOGGER(DEBUG) << "content_info is null";
+
+  std::shared_ptr<const wgt::parse::ContentInfo> content_info;
+  if (application_data_) {
+    content_info.reset(application_data_->content_info());
+    if (content_info) {
+      src = content_info->src();
+      type = content_info->type();
+      encoding = content_info->encoding();
+      LOGGER(DEBUG) << "src: " << src;
+      LOGGER(DEBUG) << "type: " << type;
+      LOGGER(DEBUG) << "encoding: " << encoding;
+    } else {
+      LOGGER(DEBUG) << "content_info is null";
+    }
   }
 
   // Check that tizen:content src is external page
@@ -579,7 +585,16 @@ std::string ResourceManager::DecryptResource(const std::string& path) {
 
   // Read filesize
   fseek(src, 0, SEEK_END);
-  size_t src_len = ftell(src);
+
+  size_t src_len = 0;
+  int ret = ftell(src);
+  if (ret < 0) {
+    LOGGER(ERROR) << "Cannot get filesize of " << src_path;
+    return path;
+  } else {
+    src_len = static_cast<size_t>(ret);
+  }
+
   if (src_len == 0) {
     // if the file exists and is empty, bypass it
     fclose(src);
index 51b4c02..2237501 100644 (file)
@@ -366,7 +366,9 @@ WidgetPreferenceDB* WidgetPreferenceDB::GetInstance() {
   return &instance;
 }
 
-WidgetPreferenceDB::WidgetPreferenceDB() {
+WidgetPreferenceDB::WidgetPreferenceDB()
+    : appdata_(nullptr),
+      locale_manager_(nullptr) {
 }
 WidgetPreferenceDB::~WidgetPreferenceDB() {
 }
index 82a2d87..ed686c1 100644 (file)
@@ -162,26 +162,27 @@ void Popup::SetButtonType(ButtonType type) {
   enable_button_ = true;
   switch (type) {
     case ButtonType::OkButton:
-    button1_ = AddButton(this, popup_string::kPopupButtonOk,
-                         kContentButton1);
-    break;
+      button1_ = AddButton(this, popup_string::kPopupButtonOk,
+                           kContentButton1);
+      break;
     case ButtonType::OkCancelButton:
-    button1_ = AddButton(this, popup_string::kPopupButtonCancel,
-                         kContentButton1);
-    button2_ = AddButton(this, popup_string::kPopupButtonOk,
-                         kContentButton2);
+      button1_ = AddButton(this, popup_string::kPopupButtonCancel,
+                           kContentButton1);
+      button2_ = AddButton(this, popup_string::kPopupButtonOk,
+                           kContentButton2);
+      break;
     case ButtonType::LoginCancelButton:
-    button1_ = AddButton(this, popup_string::kPopupButtonCancel,
-                         kContentButton1);
-    button2_ = AddButton(this, popup_string::kPopupButtonLogin,
-                         kContentButton2);
-    break;
+      button1_ = AddButton(this, popup_string::kPopupButtonCancel,
+                           kContentButton1);
+      button2_ = AddButton(this, popup_string::kPopupButtonLogin,
+                           kContentButton2);
+      break;
     case ButtonType::AllowDenyButton:
-    button1_ = AddButton(this, popup_string::kPopupButtonDeny,
-                         kContentButton1);
-    button2_ = AddButton(this, popup_string::kPopupButtonAllow,
-                         kContentButton2);
-    break;
+      button1_ = AddButton(this, popup_string::kPopupButtonDeny,
+                           kContentButton1);
+      button2_ = AddButton(this, popup_string::kPopupButtonAllow,
+                           kContentButton2);
+      break;
   }
 }
 
index 318c07b..8bc89f8 100644 (file)
@@ -100,10 +100,11 @@ SplashScreen::SplashScreen(
     runtime::NativeWindow* window,
     std::shared_ptr<const wgt::parse::SplashScreenInfo> ss_info,
     const std::string& app_path)
-    : window_(window),
-      ss_info_(ss_info),
+    : ss_info_(ss_info),
+      window_(window),
       image_(nullptr),
       background_(nullptr),
+      background_image_(nullptr),
       is_active_(false) {
   LOGGER(DEBUG) << "start of create splash screen";
   if (ss_info == nullptr) return;
index f2d7958..9470d98 100644 (file)
@@ -76,6 +76,7 @@ WebViewImpl::WebViewImpl(WebView* view,
       context_(context),
       ewk_view_(NULL),
       listener_(NULL),
+      rotation_handler_id_(0),
       view_(view),
       fullscreen_(false),
       evas_smart_class_(NULL),