From ff7a80e592faf5e2dc2f479dad1e2b0b1be7cac2 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 28 Oct 2022 14:14:38 -0700 Subject: [PATCH] dmnt: allow string termination to end a toggle (closes #1980) --- stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index c23d1c9c0..627c56bdd 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -1025,13 +1025,16 @@ namespace ams::dmnt::cheat::impl { /* Skip whitespace. */ while (std::isspace(static_cast(s[i]))) { i++; + if (i >= len) { + return false; + } } /* Parse whether to toggle. */ j = i + 1; - while (!std::isspace(static_cast(s[j]))) { + while (j < len && !std::isspace(static_cast(s[j]))) { j++; - if (j >= len || (j - i) >= sizeof(toggle)) { + if ((j - i) >= sizeof(toggle)) { return false; } }