Added negative index protections into GetCHRAddress to protect against a large unsigned number being passed and interpretted as a negative number. Caught by gcc UBSAN.
This commit is contained in:
parent
293fc7b672
commit
4dd8943724
21
src/ppu.cpp
21
src/ppu.cpp
|
@ -456,13 +456,24 @@ volatile int rendercount, vromreadcount, undefinedvromcount, LogAddress = -1;
|
|||
unsigned char *cdloggervdata = NULL;
|
||||
unsigned int cdloggerVideoDataSize = 0;
|
||||
|
||||
int GetCHRAddress(int A) {
|
||||
if (cdloggerVideoDataSize) {
|
||||
int result = &VPage[A >> 10][A] - CHRptr[0];
|
||||
int GetCHRAddress(int A)
|
||||
{
|
||||
if (cdloggerVideoDataSize)
|
||||
{
|
||||
int result = -1;
|
||||
if ( (A >= 0) && (A < 0x2000) )
|
||||
{
|
||||
result = &VPage[A >> 10][A] - CHRptr[0];
|
||||
}
|
||||
if ((result >= 0) && (result < (int)cdloggerVideoDataSize))
|
||||
{
|
||||
return result;
|
||||
} else
|
||||
if(A < 0x2000) return A;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (A >= 0) && (A < 0x2000) ) return A;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue