Make sure hidapi error handling is thread-safe

The hidapi method of storing the error on the device is not thread-safe, and not only could it result in a double free if multiple threads were setting the error at the same time, but SDL could be trying to use the error message and have it be freed out from under it by another thread.

Use SDL's error functions since they already use thread-local storage.
This commit is contained in:
Sam Lantinga
2023-05-26 23:48:09 -07:00
parent d51f84a2e1
commit bc28790817
6 changed files with 46 additions and 101 deletions

View File

@@ -20,7 +20,6 @@
*/
/* Define standard library functions in terms of SDL */
#define HIDAPI_USING_SDL_RUNTIME
#define free SDL_free
#define iconv_t SDL_iconv_t
#define ICONV_CONST