Vitaliy Margolen : dinput: Fix usage of HeapReAlloc.
Module: wine Branch: master Commit: a610cfb64c16179b718a0559932375fc83571c65 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a610cfb64c16179b718a055993... Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sun Dec 28 13:40:47 2008 -0700 dinput: Fix usage of HeapReAlloc. --- dlls/dinput/joystick_linuxinput.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index a08a5b7..b07166c 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -228,6 +228,7 @@ static void find_joydevs(void) int fd; int no_ff_check = 0; int j; + struct JoyDev *new_joydevs; snprintf(buf, sizeof(buf), EVDEVPREFIX"%d", i); @@ -319,12 +320,18 @@ static void find_joydevs(void) } } - if (have_joydevs==0) { - joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev)); - } else { - HeapReAlloc(GetProcessHeap(), 0, joydevs, (1+have_joydevs) * sizeof(struct JoyDev)); - } - memcpy(joydevs+have_joydevs, &joydev, sizeof(struct JoyDev)); + if (!have_joydevs) + new_joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev)); + else + new_joydevs = HeapReAlloc(GetProcessHeap(), 0, joydevs, (1 + have_joydevs) * sizeof(struct JoyDev)); + + if (!new_joydevs) + { + close(fd); + continue; + } + joydevs = new_joydevs; + memcpy(joydevs + have_joydevs, &joydev, sizeof(joydev)); have_joydevs++; }
participants (1)
-
Alexandre Julliard