1
0
Fork 0

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.
This commit is contained in:
Patryk Obara 2019-12-07 18:23:51 +01:00 committed by Patryk Obara
parent fe519d0344
commit 496611b2ce

View file

@ -20,7 +20,7 @@
#include "dosbox.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <cctype>
#include <string>
#include <vector>
#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);