Forgot to alloc the hwdata when opening from joystick. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 06 Aug 2008 09:28:07 +0000
branchgsoc2008_force_feedback
changeset 2621 83659de20bf2
parent 2620 4d91a53c6f8a
child 2622 446054caaa81
Forgot to alloc the hwdata when opening from joystick.
src/haptic/win32/SDL_syshaptic.c
--- a/src/haptic/win32/SDL_syshaptic.c	Wed Aug 06 09:24:08 2008 +0000
+++ b/src/haptic/win32/SDL_syshaptic.c	Wed Aug 06 09:28:07 2008 +0000
@@ -565,6 +565,16 @@
 {
    int ret;
 
+   /* Allocate the hwdata */
+   haptic->hwdata = (struct haptic_hwdata *)
+         SDL_malloc(sizeof(*haptic->hwdata));
+   if (haptic->hwdata == NULL) {
+      SDL_OutOfMemory();
+      return -1;
+   }
+   SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
+
+   /* Now open the device. */
    ret = SDL_SYS_HapticOpenFromDevice2( haptic, joystick->hwdata->InputDevice );  
    if (ret < 0) {
       return -1;