Fixed Coverity 'High Impact Outstanding' issues:

1489113
1489111
1489105
1489096
1489093
1489092
1486059
1486055 (false positive)
1486054
1486051 (false positive)
1486050
1486047 (false positive)
1486043
1446684
This commit is contained in:
tomcw 2020-01-04 17:43:20 +00:00
parent edf65762cd
commit 087616db29
6 changed files with 25 additions and 15 deletions

View File

@ -1682,9 +1682,7 @@ static void GetAppleWinVersion(void)
char szPath[_MAX_PATH];
if (0 == GetModuleFileName(NULL, szPath, sizeof(szPath)))
{
strcpy(szPath, __argv[0]);
}
strcpy_s(szPath, sizeof(szPath), __argv[0]);
// Extract application version and store in a global variable
DWORD dwHandle, dwVerInfoSize;

View File

@ -7037,7 +7037,7 @@ Update_t CmdWatchAdd (int nArgs)
if (iWatch == NO_6502_TARGET)
{
iWatch = 0;
while ((iWatch < MAX_ZEROPAGE_POINTERS) && (g_aWatches[iWatch].bSet))
while ((iWatch < MAX_WATCHES) && (g_aWatches[iWatch].bSet))
{
iWatch++;
}

View File

@ -125,7 +125,7 @@ WORD _CmdDefineByteRange(int nArgs,int iArg,DisasmData_t & tData_)
// TODO: Note: need to call ConsoleUpdate(), as may print symbol has been updated
strcpy( tData_.sSymbol, pSymbolName );
strcpy_s( tData_.sSymbol, sizeof(tData_.sSymbol), pSymbolName );
return nAddress;
}

View File

@ -56,6 +56,7 @@ ImageInfo::ImageInfo()
pImageBuffer = NULL;
pTrackMap = NULL;
optimalBitTiming = 0;
maxNibblesPerTrack = 0;
}
/* DO logical order 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@ -123,11 +124,12 @@ bool CImageBase::WriteTrack(ImageInfo* pImageInfo, const int nTrack, LPBYTE pTra
return false;
int nLen = gzwrite(hGZFile, pImageInfo->pImageBuffer, pImageInfo->uImageSize);
int nRes = gzclose(hGZFile); // close before returning (due to error) to avoid resource leak
hGZFile = NULL;
if (nLen != pImageInfo->uImageSize)
return false;
int nRes = gzclose(hGZFile);
hGZFile = NULL;
if (nRes != Z_OK)
return false;
}
@ -244,11 +246,12 @@ bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlo
return false;
int nLen = gzwrite(hGZFile, pImageInfo->pImageBuffer, pImageInfo->uImageSize);
int nRes = gzclose(hGZFile); // close before returning (due to error) to avoid resource leak
hGZFile = NULL;
if (nLen != pImageInfo->uImageSize)
return false;
int nRes = gzclose(hGZFile);
hGZFile = NULL;
if (nRes != Z_OK)
return false;
}
@ -1398,11 +1401,12 @@ ImageError_e CImageHelperBase::CheckGZipFile(LPCTSTR pszImageFilename, ImageInfo
pImageInfo->pImageBuffer = new BYTE[MAX_UNCOMPRESSED_SIZE];
int nLen = gzread(hGZFile, pImageInfo->pImageBuffer, MAX_UNCOMPRESSED_SIZE);
int nRes = gzclose(hGZFile); // close before returning (due to error) to avoid resource leak
hGZFile = NULL;
if (nLen < 0 || nLen == MAX_UNCOMPRESSED_SIZE)
return eIMAGE_ERROR_BAD_SIZE;
int nRes = gzclose(hGZFile);
hGZFile = NULL;
if (nRes != Z_OK)
return eIMAGE_ERROR_GZ;

View File

@ -1836,8 +1836,8 @@ void MemReset()
for( int i = 0; i < 256; i++ )
{
clock = getRandomTime();
random[ (i+0) & 0xFF ] ^= (clock >> 0) & 0xFF;
random[ (i+1) & 0xFF ] ^= (clock >> 11) & 0xFF;
random[ (i+0) & 0xFF ] = (clock >> 0) & 0xFF;
random[ (i+1) & 0xFF ] = (clock >> 11) & 0xFF;
}
memcpy( &memmain[ iByte ], random, 256 );

View File

@ -239,7 +239,7 @@ int GH445_test_jmp(BYTE op)
const WORD target16 = 0x1234;
int target0, target1, target2;
int target0=0, target1=0, target2=0;
if (op == OPCODE_JMP_A)
{
target0 = NO_6502_TARGET;
@ -262,6 +262,10 @@ int GH445_test_jmp(BYTE op)
mem[target0] = target2 & 0xff;
mem[target1] = (target2>>8) & 0xff;
}
else
{
_ASSERT(0);
}
mem[regs.pc] = op;
mem[(regs.pc+1)&0xFFFF] = (BYTE) (target16&0xff);
@ -542,7 +546,7 @@ int GH451_test_jmp(BYTE op)
const WORD target16 = 0x1234;
int target0, target1;
int target0=0, target1=0;
if (op == OPCODE_JMP_A)
{
target0 = NO_6502_TARGET;
@ -558,6 +562,10 @@ int GH451_test_jmp(BYTE op)
target0 = (target16+regs.x)&0xffff;
target1 = (target16+regs.x+1)&0xffff;
}
else
{
_ASSERT(0);
}
mem[regs.pc] = op;
mem[(regs.pc+1)&0xFFFF] = (BYTE) (target16&0xff);