mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 00:42:24 +00:00
TINSEL: Fix UB for enum TINSEL_EVENT in DW2. PVS-Studio V1016
In DW2, some large TINSEL_EVENT values are read, and they're bigger than the last TINSEL_EVENT value, but we cast them to `enum TINSEL_EVENT` values in tinlib.cpp, which is apparently "unspecified behavior up to C++17 and undefined behavior starting from C++17". tinlib.cpp:1925:39: runtime error: load of value 9041, which is not a valid value for type 'Tinsel::TINSEL_EVENT' tinlib.cpp:1935:31: runtime error: load of value 77, which is not a valid value for type 'Tinsel::TINSEL_EVENT' Found with UBSan but the really clear help comes from PVS-Studio documentation.
This commit is contained in:
parent
c690a3e985
commit
21cd732b60
@ -87,7 +87,8 @@ enum PLR_EVENT {
|
||||
*
|
||||
* Note: DW2 renames ENTER & LEAVE to WALKIN & WALKOUT, and has a new LEAVE event
|
||||
*/
|
||||
enum TINSEL_EVENT {
|
||||
// ': int' because out-of-range values happen in DW2 and we do enum casts (PVS-Studio V1016)
|
||||
enum TINSEL_EVENT : int {
|
||||
NOEVENT, STARTUP, CLOSEDOWN, POINTED, UNPOINT, WALKIN, WALKOUT,
|
||||
PICKUP, PUTDOWN, WALKTO, LOOK, ACTION, CONVERSE, SHOWEVENT,
|
||||
HIDEEVENT, TALKING, ENDTALK, LEAVE_T2, RESTORE, PROV_WALKTO
|
||||
|
Loading…
x
Reference in New Issue
Block a user