From 3e97160a2b58b9e7db9f0b8f9a57b3fdf9422736 Mon Sep 17 00:00:00 2001 From: liduo Date: Tue, 27 Aug 2024 15:25:23 +0800 Subject: [PATCH] fix id overflow Signed-off-by: liduo --- include/config_parser.h | 4 ++-- src/config_parser.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/config_parser.h b/include/config_parser.h index 979d1da..544f497 100644 --- a/include/config_parser.h +++ b/include/config_parser.h @@ -91,8 +91,8 @@ private: std::string moduleName_; ModuleType moduleType_; std::string mainAbility_; - int32_t abilityIconId_; - int32_t abilityLabelId_; + int64_t abilityIconId_; + int64_t abilityLabelId_; std::map> jsonCheckIds_; static const std::map MODULE_TYPES; static const std::map JSON_STRING_IDS; diff --git a/src/config_parser.cpp b/src/config_parser.cpp index 2e96cd4..15b3d27 100644 --- a/src/config_parser.cpp +++ b/src/config_parser.cpp @@ -379,7 +379,7 @@ bool ConfigParser::ParseJsonArrayRef(cJSON *parent, const string &key, cJSON *no return false; } if (update) { - cJSON_AddItemToArray(array, cJSON_CreateNumber(atoi(value.c_str()))); + cJSON_AddItemToArray(array, cJSON_CreateNumber(atoll(value.c_str()))); } } cJSON_AddItemToObject(parent, (key + "Id").c_str(), array); @@ -407,8 +407,8 @@ bool ConfigParser::ParseJsonStringRef(cJSON *parent, const string &key, cJSON *n return false; } if (update) { - cJSON_AddItemToObject(parent, (key + "Id").c_str(), cJSON_CreateNumber(atoi(value.c_str()))); - AddCheckNode(key, static_cast(atoi(value.c_str()))); + cJSON_AddItemToObject(parent, (key + "Id").c_str(), cJSON_CreateNumber(atoll(value.c_str()))); + AddCheckNode(key, static_cast(atoll(value.c_str()))); } return true; }