Module: wine Branch: master Commit: 5085d4cd35b314bacb4e9eb491a45de513ca2d50 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5085d4cd35b314bacb4e9eb491...
Author: Vitaliy Margolen wine-patches@kievinfo.com Date: Sun Sep 14 11:05:55 2008 -0600
dinput: Replace strdup with HeapAlloc.
---
dlls/dinput/joystick_linuxinput.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index a7c9c63..6b3a186 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -264,14 +264,18 @@ static void find_joydevs(void) ) ) {
- joydev.device = strdup(buf); + if (!(joydev.device = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1))) { + close(fd); + continue; + } + strcpy(joydev.device, buf);
- if (-1!=ioctl(fd, EVIOCGNAME(MAX_PATH-1), buf)) { - buf[MAX_PATH-1] = 0; - joydev.name = strdup(buf); - } else { + buf[MAX_PATH - 1] = 0; + if (ioctl(fd, EVIOCGNAME(MAX_PATH - 1), buf) != -1 && + (joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1))) + strcpy(joydev.name, buf); + else joydev.name = joydev.device; - }
joydev.guid = DInput_Wine_Joystick_Base_GUID; joydev.guid.Data3 += have_joydevs;