diff --git a/include/id_worker.h b/include/id_worker.h index 8e89903..8ac64ce 100644 --- a/include/id_worker.h +++ b/include/id_worker.h @@ -33,7 +33,7 @@ public: std::vector GetHeaderId() const; int64_t GetId(ResType resType, const std::string &name) const; int64_t GetSystemId(ResType resType, const std::string &name) const; - void LoadIdFromHap(std::map> &items); + int64_t LoadIdFromHap(std::map> &items); private: int64_t GenerateAppId(ResType resType, const std::string &name); diff --git a/src/id_worker.cpp b/src/id_worker.cpp index 010d527..0daa55a 100644 --- a/src/id_worker.cpp +++ b/src/id_worker.cpp @@ -84,7 +84,7 @@ int64_t IdWorker::GetSystemId(ResType resType, const string &name) const return result->second.id; } -void IdWorker::LoadIdFromHap(map> &items) +int64_t IdWorker::LoadIdFromHap(map> &items) { int64_t minId = 0xffffffff; int64_t maxId = 0x01000000; @@ -97,7 +97,12 @@ void IdWorker::LoadIdFromHap(map> &items) maxId = max(maxId, item.first); } maxId_ = GetMaxId(minId); - appId_ = maxId + 1; + if (static_cast(maxId) > maxId_) { + PrintError(GetError(ERR_CODE_RESOURCE_ID_EXCEED).FormatCause(static_cast(maxId), maxId_)); + return RESTOOL_ERROR; + } + appId_ = static_cast(maxId) + 1; + return RESTOOL_SUCCESS; } int64_t IdWorker::GenerateAppId(ResType resType, const string &name) diff --git a/src/resource_overlap.cpp b/src/resource_overlap.cpp index 9dc1e3a..8934794 100644 --- a/src/resource_overlap.cpp +++ b/src/resource_overlap.cpp @@ -88,7 +88,9 @@ uint32_t ResourceOverlap::LoadHapResources() return RESTOOL_ERROR; } - IdWorker::GetInstance().LoadIdFromHap(items); + if (IdWorker::GetInstance().LoadIdFromHap(items) != RESTOOL_SUCCESS) { + return RESTOOL_ERROR; + } FileManager &fileManager = FileManager::GetInstance(); fileManager.SetModuleName(moduleName_); diff --git a/src/resource_pack.cpp b/src/resource_pack.cpp index e835a2c..4fbbc9d 100644 --- a/src/resource_pack.cpp +++ b/src/resource_pack.cpp @@ -47,7 +47,11 @@ uint32_t ResourcePack::Package() } unique_ptr resourcePacker = ResourcePackerFactory::CreatePacker(packType_, packageParser_); - errorCode = resourcePacker->Pack(); + if (!resourcePacker) { + errorCode = RESTOOL_ERROR; + } else { + errorCode = resourcePacker->Pack(); + } } if (errorCode == RESTOOL_SUCCESS) { ShowPackSuccess();