libmodplug
libmodplug copied to clipboard
Fix UB when calling cctype functions
Calling cctype functions, such as isspace, with negative values is undefined behaviour.
While glibc allows it, it crashes on uClibc compiled without UCLIBC_HAS_CTYPE_SIGNED
.
Fixes the undefined behaviour by casting all arguments to cctype functions to unsigned char
.
@Konstanty Any chance you can merge this please? It's been tested by the OpenDingux community and it does resolve a few playback issues. Thanks
This looks OK, though I think this library still tries to target C++98. I would recommend C-style casts instead. (@Konstanty @sezero please correct me if I am wrong.)
static_cast
is in C++98
https://en.cppreference.com/w/cpp/language/static_cast
You're right, nevermind!