diff --git a/pcsx2/Sio.cpp b/pcsx2/Sio.cpp index c21941197d..2e765f1a4b 100644 --- a/pcsx2/Sio.cpp +++ b/pcsx2/Sio.cpp @@ -433,7 +433,9 @@ SIO_WRITE memcardWrite(u8 data) case 2: transfer_size = data; - sio.buf[data + 5] = mcd->term; + // Note: coverity wrongly detects a buffer overflow. Because data + 5 could be > 512... + // So let's add a mask-nop to avoid various useless reports. + sio.buf[(data & 0xFF) + 5] = mcd->term; sio.bufSize = data + 5; checksum_pos = data + 4; break; diff --git a/pcsx2/ps2/Iop/IopHwWrite.cpp b/pcsx2/ps2/Iop/IopHwWrite.cpp index 7ba715d7ca..788e06d3da 100644 --- a/pcsx2/ps2/Iop/IopHwWrite.cpp +++ b/pcsx2/ps2/Iop/IopHwWrite.cpp @@ -270,13 +270,13 @@ static __fi void _HwWrite_16or32_Page1( u32 addr, T val ) { // ------------------------------------------------------------------------ mcase(HW_SIO_DATA): - sioWrite8( (u8)val ); - sioWrite8( (u8)(val >> 8) ); + sioWrite8( val & 0xFF ); + sioWrite8( (val >> 8) & 0xFF ); if( sizeof(T) == 4 ) { // u32 gets rid of compiler warnings when using the u16 version of this template - sioWrite8( (u8)((u32)val >> 16) ); - sioWrite8( (u8)((u32)val >> 24) ); + sioWrite8( ((u32)val >> 16) & 0xFF ); + sioWrite8( ((u32)val >> 24) & 0xFF ); } break;