Fix pkgmgr_client_usr_clear_cache_dir 64/308764/1 accepted/tizen/unified/20240401.021554 accepted/tizen/unified/x/20240401.013218
authorIlho Kim <ilho159.kim@samsung.com>
Sun, 31 Mar 2024 05:08:15 +0000 (14:08 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Sun, 31 Mar 2024 05:08:15 +0000 (14:08 +0900)
Change-Id: I73fbcf79d9d4d20d19df168f3680aab7666eeb93
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
client/src/api_stub.cc

index 04eb2c0..bff1a7a 100644 (file)
@@ -1579,7 +1579,22 @@ API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid) {
     return PKGMGR_R_EINVAL;
   }
 
-  auto* con = new Connector(PC_REQUEST);
+  pkgmgr_client_t* raw_pc =
+      static_cast<pkgmgr_client_t*>(calloc(1, sizeof(pkgmgr_client_t)));
+  if (raw_pc == nullptr) {
+    _E("out of memory");
+    return PKGMGR_R_ENOMEM;
+  }
+
+  raw_pc->pc_type = PC_REQUEST;
+
+  if (pkgmgr_client_connection_connect(raw_pc) != PKGMGR_R_OK) {
+    _E("pkgmgr_client_connection_connect fail");
+    free(raw_pc);
+    return PKGMGR_R_ECOMM;
+  }
+
+  auto* con = new Connector(PC_REQUEST, raw_pc);
   auto* proxy = con->GetCacheProxy();
   if (proxy == nullptr)
     return PKGMGR_R_EIO;