SDL_GameControllerAddMapping needs zero-terminated string (#1234)

This commit is contained in:
Libor Čapák 2017-09-11 22:28:28 +02:00 committed by Branimir Karadžić
parent e62ffe9984
commit f56687ee4b

View File

@ -496,11 +496,14 @@ namespace entry
{
bx::AllocatorI* allocator = getAllocator();
uint32_t size = (uint32_t)bx::getSize(reader);
void* data = BX_ALLOC(allocator, size);
void* data = BX_ALLOC(allocator, size + 1);
bx::read(reader, data, size);
bx::close(reader);
((char*)data)[size] = '\0';
SDL_GameControllerAddMapping( (char*)data);
if (SDL_GameControllerAddMapping( (char*)data) < 0) {
DBG("SDL game controller add mapping failed: %s", SDL_GetError());
}
BX_FREE(allocator, data);
}