Fix ResultParcelable to handle null char pointer
[platform/core/appfw/pkgmgr-info.git] / src / common / database / query_handler.cc
index a11f7cc..4bf6c36 100644 (file)
@@ -212,7 +212,7 @@ std::string QueryHandler::GetString() { return std::string(); }
 int QueryHandler::GetInt() { return 0; }
 int QueryHandler::GetRecordCount() { return 0; }
 
-std::vector<std::vector<std::string>> QueryHandler::GetResult() {
+std::vector<parcel::StrArgs> QueryHandler::GetResult() {
   return std::move(result_);
 }
 
@@ -268,9 +268,12 @@ int QueryHandler::Execute() {
 
       GList* tmp = list;
       for (int i = 0; i < row; ++i) {
-        std::vector<std::string> vt;
+        parcel::StrArgs vt;
         for (int j = 0; j < col; ++j) {
-          vt.emplace_back(reinterpret_cast<char *>(tmp->data));
+          if (!tmp->data)
+            vt.emplace_back(std::nullopt);
+          else
+            vt.emplace_back(reinterpret_cast<char *>(tmp->data));
           tmp = tmp->next;
         }
         result_.emplace_back(std::move(vt));