mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Hotfix] Fix sigabort crash from invalid JSON
This commit is contained in:
parent
88580b69b6
commit
d41725e325
@ -45,10 +45,22 @@ struct LootStateData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool IsValidJson(const std::string& json) {
|
||||||
|
rapidjson::Document doc;
|
||||||
|
rapidjson::ParseResult result = doc.Parse(json.c_str());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
inline void LoadLootStateData(Zone *zone, NPC *npc, const std::string &loot_data)
|
inline void LoadLootStateData(Zone *zone, NPC *npc, const std::string &loot_data)
|
||||||
{
|
{
|
||||||
LootStateData l{};
|
LootStateData l{};
|
||||||
|
|
||||||
|
if (!IsValidJson(loot_data)) {
|
||||||
|
LogZoneState("Invalid JSON data for NPC [{}]", npc->GetNPCTypeID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
{
|
{
|
||||||
@ -166,6 +178,11 @@ inline std::string GetLootSerialized(Corpse *c)
|
|||||||
|
|
||||||
inline void LoadNPCEntityVariables(NPC *n, const std::string &entity_variables)
|
inline void LoadNPCEntityVariables(NPC *n, const std::string &entity_variables)
|
||||||
{
|
{
|
||||||
|
if (!IsValidJson(entity_variables)) {
|
||||||
|
LogZoneState("Invalid JSON data for NPC [{}]", n->GetNPCTypeID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::map<std::string, std::string> deserialized_map;
|
std::map<std::string, std::string> deserialized_map;
|
||||||
try {
|
try {
|
||||||
std::istringstream is(entity_variables);
|
std::istringstream is(entity_variables);
|
||||||
@ -186,6 +203,11 @@ inline void LoadNPCEntityVariables(NPC *n, const std::string &entity_variables)
|
|||||||
|
|
||||||
inline void LoadNPCBuffs(NPC *n, const std::string &buffs)
|
inline void LoadNPCBuffs(NPC *n, const std::string &buffs)
|
||||||
{
|
{
|
||||||
|
if (!IsValidJson(buffs)) {
|
||||||
|
LogZoneState("Invalid JSON data for NPC [{}]", n->GetNPCTypeID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Buffs_Struct> valid_buffs;
|
std::vector<Buffs_Struct> valid_buffs;
|
||||||
try {
|
try {
|
||||||
std::istringstream is(buffs);
|
std::istringstream is(buffs);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user