操作json配置时先判断有无该字段,解决402卡死的问题

This commit is contained in:
yangjiaxuan 2023-11-09 11:16:36 +08:00
parent 28b7395b68
commit 87874c6cc4
1 changed files with 7 additions and 4 deletions

View File

@ -3374,12 +3374,15 @@ void hg_scanner::erase_option(const char* name)
} }
void hg_scanner::erase_range(const char* name, const char* opt_name) void hg_scanner::erase_range(const char* name, const char* opt_name)
{ {
for (size_t i = 0; i < setting_jsn_.at(name).at("range").size(); i++) if (setting_jsn_.count(name) && setting_jsn_.at(name).count("range") > 0)
{ {
if (setting_jsn_.at(name).at("range").at(i) == opt_name) for (size_t i = 0; i < setting_jsn_.at(name).at("range").size(); i++)
{ {
setting_jsn_.at(name).at("range").erase(i); if (setting_jsn_.at(name).at("range").at(i) == opt_name)
break; {
setting_jsn_.at(name).at("range").erase(i);
break;
}
} }
} }
} }