Donovan Watteau 21cd732b60 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.
2022-11-29 00:41:03 +01:00
..