[package] Fixed potential dereference of nullptr 44/309144/2 accepted/tizen_unified accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen accepted/tizen/unified/20240410.084246 accepted/tizen/unified/x/20240411.011801 accepted/tizen/unified/x/asan/20240415.123246
authorPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Fri, 5 Apr 2024 06:15:25 +0000 (08:15 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Tue, 9 Apr 2024 06:27:57 +0000 (06:27 +0000)
[Verification] Compiles without error.

Change-Id: Ic3af3b88a53077bacb7cbe4abfc17038910b4557

src/package/package_info_provider.cc

index 5844fac..acd077d 100644 (file)
@@ -234,6 +234,11 @@ namespace {
 void GetSize(const std::string& id, int service_mode, picojson::object* out) {
   ScopeLogger();
   pkgmgr_client* pc = pkgmgr_client_new(PC_REQUEST);
+  if (!pc) {
+    LogAndReportError(
+        PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get size"), out,
+        ("pkgmgr_client_new returned nullptr"));
+  }
   int size = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, service_mode, pc, NULL,
                                                id.c_str(), getuid(), NULL, NULL, NULL);
   pkgmgr_client_free(pc);