Fix zero-size calloc when enumerating a joystick with no hats in Windows.

git-svn-id: https://svn.eduke32.com/eduke32@2323 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-02-09 22:43:21 +00:00
parent 75436815c3
commit dbada3c947

View file

@ -1155,10 +1155,12 @@ static BOOL InitDirectInput(void)
axisdefs = (struct _joydef *)Bcalloc(didc.dwAxes, sizeof(struct _joydef)); axisdefs = (struct _joydef *)Bcalloc(didc.dwAxes, sizeof(struct _joydef));
buttondefs = (struct _joydef *)Bcalloc(didc.dwButtons, sizeof(struct _joydef)); buttondefs = (struct _joydef *)Bcalloc(didc.dwButtons, sizeof(struct _joydef));
hatdefs = (struct _joydef *)Bcalloc(didc.dwPOVs, sizeof(struct _joydef)); if (didc.dwPOVs)
hatdefs = (struct _joydef *)Bcalloc(didc.dwPOVs, sizeof(struct _joydef));
joyaxis = (int32_t *)Bcalloc(didc.dwAxes, sizeof(int32_t)); joyaxis = (int32_t *)Bcalloc(didc.dwAxes, sizeof(int32_t));
joyhat = (int32_t *)Bcalloc(didc.dwPOVs, sizeof(int32_t)); if (didc.dwPOVs)
joyhat = (int32_t *)Bcalloc(didc.dwPOVs, sizeof(int32_t));
result = IDirectInputDevice7_EnumObjects(dev2, InitDirectInput_enumobjects, (LPVOID)typecounts, DIDFT_ALL); result = IDirectInputDevice7_EnumObjects(dev2, InitDirectInput_enumobjects, (LPVOID)typecounts, DIDFT_ALL);
if (FAILED(result)) { IDirectInputDevice7_Release(dev2); HorribleDInputDeath("Failed getting controller features", result); } if (FAILED(result)) { IDirectInputDevice7_Release(dev2); HorribleDInputDeath("Failed getting controller features", result); }