From 07ee870601163a3f80b769b50805dc485ca02ab9 Mon Sep 17 00:00:00 2001 From: LuChiChick <1084116302@qq.com> Date: Thu, 23 Apr 2026 11:10:38 +0800 Subject: [PATCH] Added null pointer checks && Removed duplicate file existence checks. --- Src/Json_Utilities.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Src/Json_Utilities.cpp b/Src/Json_Utilities.cpp index 0fc8c1e..28dafcd 100644 --- a/Src/Json_Utilities.cpp +++ b/Src/Json_Utilities.cpp @@ -407,10 +407,12 @@ std::string JsonFile_Parse(const char *path_to_file, Json_Value *pJson_Value) if (!err_str.empty()) return err_str; - // 尝试打开文件 + // 检查空指针 + if (pJson_Value == nullptr) + return "Null container ptr."; + + // 打开已完成检查的文件 FILE *pFile = fopen(path_to_file, "rb"); - if (pFile == nullptr) - return "file \"" + std::string(path_to_file) + "\" open failed."; // 跳过空白部分 return -> skip count auto Lambda_skip_blank = [&](void) -> size_t