SDL/src/stdlib
Sam Lantinga 342f62ca69 Fixed bug 5022 - SDL_iconv_string can get stuck in an infinite loop when encountering invalid characters
ciremo6483

In `SDL_iconv_string` the `while (inbytesleft > 0)` loop can end up in a state where it never terminates because the library `iconv` function called from `SDL_iconv` doesn't consume any bytes.

This happened when a `WCHAR_T` input string was being converted to `UTF-8` but contained invalid characters. It would first It would first skip a few bytes due to `case SDL_ICONV_EILSEQ` but when there were 3 bytes remaining of `inbytesleft` `iconv` just didn't consume anything more (but didn't throw an error either).

It just so happens that the Microsoft Classic IntelliMouse `product_string` contains such invalid characters (`"Microsoft? Classic IntelliMouse?"`), meaning the function would get stuck with said mouse plugged in.

A fix for this would be to check if `inbytesleft` was unchanged after an iteration and in that case either decrement the counter like when `SDL_ICONV_EILSEQ` is returned or simply break the loop.
2020-03-10 16:29:28 -07:00
..
SDL_getenv.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_iconv.c Fixed bug 5022 - SDL_iconv_string can get stuck in an infinite loop when encountering invalid characters 2020-03-10 16:29:28 -07:00
SDL_malloc.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_qsort.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_stdlib.c Fixed bug 5001 - Feature request: SDL_isupper & SDL_islower 2020-03-02 15:21:07 -08:00
SDL_string.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_strtokr.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00