mirror of https://github.com/encounter/SDL.git
Fixed crash if manufacturer or product string is NULL
This commit is contained in:
parent
255c9c23d4
commit
d662a65964
|
@ -699,15 +699,27 @@ HIDAPI_AddDevice(struct hid_device_info *info)
|
||||||
|
|
||||||
/* Need the device name before getting the driver to know whether to ignore this device */
|
/* Need the device name before getting the driver to know whether to ignore this device */
|
||||||
{
|
{
|
||||||
char *manufacturer_string = SDL_iconv_string("UTF-8", "WCHAR_T", (char*)info->manufacturer_string, (SDL_wcslen(info->manufacturer_string)+1)*sizeof(wchar_t));
|
char *manufacturer_string = NULL;
|
||||||
char *product_string = SDL_iconv_string("UTF-8", "WCHAR_T", (char*)info->product_string, (SDL_wcslen(info->product_string)+1)*sizeof(wchar_t));
|
char *product_string = NULL;
|
||||||
if (!manufacturer_string && !product_string) {
|
|
||||||
if (sizeof(wchar_t) == sizeof(Uint16)) {
|
if (info->manufacturer_string) {
|
||||||
manufacturer_string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char*)info->manufacturer_string, (SDL_wcslen(info->manufacturer_string)+1)*sizeof(wchar_t));
|
manufacturer_string = SDL_iconv_string("UTF-8", "WCHAR_T", (char*)info->manufacturer_string, (SDL_wcslen(info->manufacturer_string)+1)*sizeof(wchar_t));
|
||||||
product_string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char*)info->product_string, (SDL_wcslen(info->product_string)+1)*sizeof(wchar_t));
|
if (!manufacturer_string) {
|
||||||
} else if (sizeof(wchar_t) == sizeof(Uint32)) {
|
if (sizeof(wchar_t) == sizeof(Uint16)) {
|
||||||
manufacturer_string = SDL_iconv_string("UTF-8", "UCS-4-INTERNAL", (char*)info->manufacturer_string, (SDL_wcslen(info->manufacturer_string)+1)*sizeof(wchar_t));
|
manufacturer_string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char*)info->manufacturer_string, (SDL_wcslen(info->manufacturer_string)+1)*sizeof(wchar_t));
|
||||||
product_string = SDL_iconv_string("UTF-8", "UCS-4-INTERNAL", (char*)info->product_string, (SDL_wcslen(info->product_string)+1)*sizeof(wchar_t));
|
} else if (sizeof(wchar_t) == sizeof(Uint32)) {
|
||||||
|
manufacturer_string = SDL_iconv_string("UTF-8", "UCS-4-INTERNAL", (char*)info->manufacturer_string, (SDL_wcslen(info->manufacturer_string)+1)*sizeof(wchar_t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (info->product_string) {
|
||||||
|
product_string = SDL_iconv_string("UTF-8", "WCHAR_T", (char*)info->product_string, (SDL_wcslen(info->product_string)+1)*sizeof(wchar_t));
|
||||||
|
if (!product_string) {
|
||||||
|
if (sizeof(wchar_t) == sizeof(Uint16)) {
|
||||||
|
product_string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char*)info->product_string, (SDL_wcslen(info->product_string)+1)*sizeof(wchar_t));
|
||||||
|
} else if (sizeof(wchar_t) == sizeof(Uint32)) {
|
||||||
|
product_string = SDL_iconv_string("UTF-8", "UCS-4-INTERNAL", (char*)info->product_string, (SDL_wcslen(info->product_string)+1)*sizeof(wchar_t));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue