From 4181f6f04969fac9cf79d53aa43f32b64d314ef5 Mon Sep 17 00:00:00 2001 From: Cole Avenue Date: Tue, 23 Jun 2026 22:01:51 -0500 Subject: [PATCH] [fs] fix crash on '#' comments in pchtxt patches Adds `#` as a valid pchtxt comment, and fixes a crash that could occur when using odd-length values This patch was sent by Adam Kittelson Signed-off-by: crueter --- src/common/hex_util.cpp | 2 +- src/core/file_sys/ips_layer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/hex_util.cpp b/src/common/hex_util.cpp index 07053295c0..b5e0b97ee5 100644 --- a/src/common/hex_util.cpp +++ b/src/common/hex_util.cpp @@ -12,7 +12,7 @@ std::vector HexStringToVector(std::string_view str, bool little_endian) { for (std::size_t i = str.size() - 2; i <= str.size(); i -= 2) out[i / 2] = (ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]); } else { - for (std::size_t i = 0; i < str.size(); i += 2) + for (std::size_t i = 0; i + 1 < str.size(); i += 2) out[i / 2] = (ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]); } return out; diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index 1dddd27909..62becc7847 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp @@ -256,7 +256,7 @@ void IPSwitchCompiler::Parse() { const auto& patch_line = lines[++i]; // Patch line may contain comments - if (StartsWith(patch_line, "//")) { + if (StartsWith(patch_line, "//") || StartsWith(patch_line, "#")) { continue; }