Change return type of GetRequestInfo 88/114188/1
authorSangyoon Jang <s89.jang@samsung.com>
Fri, 10 Feb 2017 07:19:53 +0000 (16:19 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Fri, 10 Feb 2017 08:40:49 +0000 (00:40 -0800)
GetRequestInfo returns const char*, but it is used as std::string.
This cause crash when the return value of GetRequestInfo is NULL.

Change-Id: I27bf835daec7eabe7c61490e38739ff0bd9079bb
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
(cherry picked from commit 7d1126de539dfad40050ee0d6719db374805f20e)

src/common/pkgmgr_interface.cc
src/common/pkgmgr_interface.h

index 586e7e6..4eb16b7 100644 (file)
@@ -125,7 +125,7 @@ RequestType PkgMgrInterface::GetRequestType() const {
   switch (pkgmgr_installer_get_request_type(pi_)) {
     case PKGMGR_REQ_INSTALL : {
       auto request_info = GetRequestInfo();
-      if (!request_info)
+      if (request_info.empty())
         return RequestType::Unknown;
       std::string extension = bf::path(request_info).extension().string();
       if (!is_app_installed_.get()) {
@@ -206,8 +206,12 @@ uid_t PkgMgrInterface::GetUid() const {
   return pkgmgr_installer_get_uid(pi_);
 }
 
-const char* PkgMgrInterface::GetRequestInfo() const {
-  return pkgmgr_installer_get_request_info(pi_);
+std::string PkgMgrInterface::GetRequestInfo() const {
+  const char* request_info = pkgmgr_installer_get_request_info(pi_);
+  if (!request_info)
+    return {};
+  else
+    return request_info;
 }
 
 boost::filesystem::path PkgMgrInterface::GetTepPath() const {
index f903a8c..86beb19 100644 (file)
@@ -82,7 +82,7 @@ class PkgMgrInterface {
    *
    * \return request info retrieved from pkgmgr_installer
    */
-  const char *GetRequestInfo() const;
+  std::string GetRequestInfo() const;
 
   /**
    * Creates PkgMgrInterface