[M120 Migration] Fix coverity issues 72/306872/2
authorManjeet <manjeet.1@partner.samsung.com>
Wed, 28 Feb 2024 12:34:10 +0000 (18:04 +0530)
committerBot Blink <blinkbot@samsung.com>
Thu, 29 Feb 2024 14:09:25 +0000 (14:09 +0000)
This commit fixes following coverity issues

CID 115640, 1027471, 1029366, 1079885, 1084336, 1273651,
1278478, 1280131, 1672601

Reference:
https://review.tizen.org/gerrit/290923

Change-Id: Ib18b5bc86bb04770114c769e28b7e40a670b13a6
Signed-off-by: Manjeet <manjeet.1@partner.samsung.com>
tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc
tizen_src/chromium_impl/content/common/paths_efl.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.cc
tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/private/ewk_app_control_private.cc
tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h
tizen_src/ewk/efl_webview_app/app.c
tizen_src/ewk/ubrowser/browser.cc

index b80d5f8..14517c1 100644 (file)
@@ -639,8 +639,7 @@ const char* ContextMenuControllerBase::GetSelectedText() {
   if (!rwhva())
     return "";
 
-  std::string selected_text = base::UTF16ToUTF8(rwhva()->GetSelectedText());
-  return selected_text.c_str();
+  return base::UTF16ToUTF8(rwhva()->GetSelectedText()).c_str();
 }
 
 }  // namespace content
index 0fd5132..cb9e93c 100644 (file)
@@ -175,7 +175,10 @@ namespace PathsEfl {
 #if BUILDFLAG(IS_TIZEN)
 FilePath GetLibRootPath(void) {
   Dl_info dl_info;
-  dladdr((void*)GetLibRootPath, &dl_info);
+  if (!dladdr((void*)GetLibRootPath, &dl_info)) {
+    LOG(ERROR) << "dladdr failed";
+    return FilePath();
+  }
   FilePath lib_root_path(dl_info.dli_fname);
   lib_root_path = MakeAbsoluteFilePath(lib_root_path);
 
index 691917c..ec09b82 100644 (file)
@@ -47,6 +47,7 @@ gfx::Rect EflScreen::GetDisplaySize() {
 EflScreen::EflScreen() {
   display::Display display(kDisplayId);
   display.set_bounds(GetDisplaySize());
+  display.set_panel_rotation(display::Display::ROTATE_0);
   display_list_.AddDisplay(display, display::DisplayList::Type::PRIMARY);
 
   screen_list.push_back(this);
index 695ffe1..36cb521 100644 (file)
@@ -68,7 +68,7 @@ void GeolocationPermissionContextEfl::RequestPermissionOnUIThread(
       std::ignore = request.release();
     else if (!request->IsDecided()) {
       // Reject permission if request is not suspended and not decided
-      std::move(callback).Run(PermissionStatus::DENIED);
+      request->RunCallback(false);
     }
   }
 }
index bb6c8c6..5e33357 100644 (file)
@@ -1419,7 +1419,7 @@ void EWebView::UpdateContextMenuWithParams(
 }
 
 Eina_Bool EWebView::DelayedPopulateAndShowContextMenu(void* data) {
-  if (IsMobileProfile) {
+  if (IsMobileProfile()) {
     EWebView* view = static_cast<EWebView*>(data);
     if (view) {
       if (view->context_menu_ &&
@@ -2170,9 +2170,9 @@ bool EWebView::GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback,
   if (!render_view_host)
     return false;
 
+#if !defined(EWK_BRINGUP)  // FIXME: m94 bringup
   MHTMLCallbackDetails* callback_details = new MHTMLCallbackDetails;
   callback_details->Set(callback, user_data);
-#if !defined(EWK_BRINGUP)  // FIXME: m94 bringup
   int mhtml_callback_id = mhtml_callback_map_.Add(callback_details);
   return render_view_host->Send(new EwkViewMsg_GetMHTMLData(
       render_view_host->GetRoutingID(), mhtml_callback_id));
index 904bee1..f59167e 100644 (file)
@@ -106,8 +106,10 @@ bool _Ewk_App_Control::ParseNavigationParams() {
   // check start : "#AppControl"
   const std::string& buf = str_tok.token();
   base::StringTokenizer check_start(buf, "#");
-  check_start.GetNext();
-  if (!check_start.GetNext() || check_start.token() != kAppControlStart) {
+  // GetNext() advances the tokenizer to the next delimiter. It's called
+  // twice here to read kAppControlStart, if any as the token value.
+  if (!check_start.GetNext() || !check_start.GetNext() ||
+      check_start.token() != kAppControlStart) {
     LOG(ERROR) << __FUNCTION__ << " > #AppControl is missing! ";
     return false;
   }
@@ -263,7 +265,7 @@ bool _Ewk_App_Control::MakeAppControl() {
       return FailHandling();
     }
 
-    ret = pkgmgrinfo_appinfo_foreach_category(
+    pkgmgrinfo_appinfo_foreach_category(
         handle,
         [](const char* category, void* user_data) -> int {
           auto app_control = static_cast<_Ewk_App_Control*>(user_data);
index 0aba688..cd6bd04 100644 (file)
 
 class _Ewk_Security_Origin;
 
+namespace content {
+class GeolocationPermissionContextEfl;
+}
+
 // This holds the geolocation permission request data.
 // The callback present is the direct engine callback which need
 // to be called once the permission is determined by app.
@@ -25,6 +29,8 @@ class _Ewk_Geolocation_Permission_Request : public Ewk_Suspendable_Object{
   _Ewk_Security_Origin* GetOrigin() const { return origin_; }
 
  private:
+  friend class content::GeolocationPermissionContextEfl;
+
   _Ewk_Security_Origin* origin_;
 
   void RunCallback(bool allowed) override;
index 4bf9636..15aaed9 100644 (file)
@@ -629,7 +629,11 @@ void __ewk_cookie_manager_async_hostnames_get_cb(Eina_List *hostnames, Ewk_Error
     printf("APP.C  calling ewk_cookie_manager_cookies_clear\n");
     if (!clear_cookie_called) {
       clear_cookie_called = EINA_TRUE;
-      printf("APP.c calling ewk_view_get_cookies_for_url:%s\n",ewk_view_get_cookies_for_url(view, start_url));
+      char* cookies = ewk_view_get_cookies_for_url(view, start_url);
+      if (cookies) {
+        printf("APP.c calling ewk_view_get_cookies_for_url:%s\n", cookies);
+        free(cookies);
+      }
       ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get(context));
       printf("APP.c calling ewk_cookie_manager_async_hostnames_with_cookies_get\n");
       ewk_cookie_manager_async_hostnames_with_cookies_get(ewk_context_cookie_manager_get(context),
index e8fbb19..80a1754 100644 (file)
@@ -257,7 +257,11 @@ void Browser::StartInspectorServer() {
 void Browser::DidStartInspectorServer(unsigned port) {
   // Get IP address.
   struct ifaddrs* addrs;
-  getifaddrs(&addrs);
+  int rc = getifaddrs(&addrs);
+  if (rc == -1) {
+    log_error("getifaddrs() failed");
+    return;
+  }
   char url[32] = {0};
   // Find non local, up IP address.
   for (struct ifaddrs* iter = addrs; iter && iter->ifa_addr;