From 496611b2ce252c6232f3bb8ed8a46718b4065b13 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sat, 7 Dec 2019 18:23:51 +0100 Subject: [PATCH] Fix out-of-bounds access error Also, fix formatting in adjacent lines. Coverity error CID 277445 says: Out-of-bounds access (ARRAY_VS_SINGLETON). Passing &ch to function upcase which uses it as an array. This might corrupt or misinterpret adjacent memory locations. --- src/dos/dos_programs.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 4b3262e3..fc4325b4 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -20,7 +20,7 @@ #include "dosbox.h" #include #include -#include +#include #include #include #include "programs.h" @@ -1036,12 +1036,12 @@ public: void LOADFIX::Run(void) { - Bit16u commandNr = 1; - Bit16u kb = 64; - if (cmd->FindCommand(commandNr,temp_line)) { - if (temp_line[0]=='-') { - char ch = temp_line[1]; - if ((*upcase(&ch)=='D') || (*upcase(&ch)=='F')) { + Bit16u commandNr = 1; + Bit16u kb = 64; + if (cmd->FindCommand(commandNr, temp_line)) { + if (temp_line[0] == '-') { + const auto ch = std::toupper(temp_line[1]); + if ((ch == 'D') || (ch == 'F')) { // Deallocate all DOS_FreeProcessMemory(0x40); WriteOut(MSG_Get("PROGRAM_LOADFIX_DEALLOCALL"),kb);