ColinPitrat / caprice32

An emulator of the Amstrad CPC 8bit home computer range.
GNU General Public License v2.0
147 stars 32 forks source link

Shifting 32-bit value by 32 bits is undefined behaviour. #183

Closed ZanyXDev closed 3 years ago

ZanyXDev commented 3 years ago

https://github.com/ColinPitrat/caprice32/blob/584d4ab6f4ce178b0a83a6a2d95119213c86fda6/src/crtc.cpp#L843 see condition https://github.com/ColinPitrat/caprice32/blob/584d4ab6f4ce178b0a83a6a2d95119213c86fda6/src/crtc.cpp#L838

ColinPitrat commented 3 years ago

You mean in case byteShift > 8? The method is never called with this but indeed, we should replace https://github.com/ColinPitrat/caprice32/blob/584d4ab6f4ce178b0a83a6a2d95119213c86fda6/src/crtc.cpp#L835

by if (byteShift >= 8) {