From e1900cd3423ce8b05d8b39dbf26e0aaa32ccdc2e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 15 Apr 2026 22:22:32 +0700 Subject: [PATCH] fix edge case in tpf unscrambling logic --- TpfConvert/src/ModfileLoader_TpfReader.ixx | 2 +- modules/ModfileLoader_TpfReader.ixx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TpfConvert/src/ModfileLoader_TpfReader.ixx b/TpfConvert/src/ModfileLoader_TpfReader.ixx index 5c14a76..59b9b35 100644 --- a/TpfConvert/src/ModfileLoader_TpfReader.ixx +++ b/TpfConvert/src/ModfileLoader_TpfReader.ixx @@ -46,7 +46,7 @@ private: [[nodiscard]] char XOR(const char b, const long position) const { - if (position > line_length - 4) { + if (position >= (line_length / 4) * 4) { return b ^ TPF_XOREven; } diff --git a/modules/ModfileLoader_TpfReader.ixx b/modules/ModfileLoader_TpfReader.ixx index 1c7e728..81410d3 100644 --- a/modules/ModfileLoader_TpfReader.ixx +++ b/modules/ModfileLoader_TpfReader.ixx @@ -46,7 +46,7 @@ private: [[nodiscard]] char XOR(const char b, const long position) const { - if (position > line_length - 4) { + if (position >= (line_length / 4) * 4) { return b ^ TPF_XOREven; }