From 4dfb47cdd9505ad37dc36d9fb5604cb502ddcf57 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 9 Apr 2022 20:16:23 +0200 Subject: [PATCH] Patch manager: check for invalid value node --- Utilities/bin_patch.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index a0d4b198b1..7a6516bd6c 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -436,8 +436,8 @@ bool patch_engine::add_patch_data(YAML::Node node, patch_info& info, u32 modifie // Check if the anchor was resolved. if (const auto yml_type = addr_node.Type(); yml_type != YAML::NodeType::Sequence) { - append_log_message(log_messages, fmt::format("Skipping sequence: expected Sequence, found %s (key: %s, location: %s)", yml_type, info.hash, get_yaml_node_location(node))); - patch_log.error("Skipping sequence: expected Sequence, found %s (key: %s, location: %s)", yml_type, info.hash, get_yaml_node_location(node)); + append_log_message(log_messages, fmt::format("Skipping patch node %s: expected Sequence, found %s (key: %s, location: %s)", info.description, yml_type, info.hash, get_yaml_node_location(node))); + patch_log.error("Skipping patch node %s: expected Sequence, found %s (key: %s, location: %s)", info.description, yml_type, info.hash, get_yaml_node_location(node)); return false; } @@ -457,10 +457,17 @@ bool patch_engine::add_patch_data(YAML::Node node, patch_info& info, u32 modifie return is_valid; } + if (const auto yml_type = value_node.Type(); yml_type != YAML::NodeType::Scalar) + { + append_log_message(log_messages, fmt::format("Skipping patch node %s. Value element has wrong type %s. (key: %s, location: %s)", info.description, yml_type, info.hash, get_yaml_node_location(node))); + patch_log.error("Skipping patch node %s. Value element has wrong type %s. (key: %s, location: %s)", info.description, yml_type, info.hash, get_yaml_node_location(node)); + return false; + } + struct patch_data p_data{}; p_data.type = type; p_data.offset = addr_node.as(0) + modifier; - p_data.original_value = value_node.IsScalar() ? value_node.Scalar() : ""; + p_data.original_value = value_node.Scalar(); std::string error_message;