Skip to content

Commit

Permalink
Zero out haptic linked list items on creation
Browse files Browse the repository at this point in the history
(thanks to Turo Lamminen for the report!)
  • Loading branch information
gabomdq committed Feb 24, 2014
1 parent 2ed47d8 commit 1084421
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/haptic/darwin/SDL_syshaptic.c
Expand Up @@ -237,7 +237,7 @@ MacHaptic_MaybeAddDevice( io_object_t device )
}
}

item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item));
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
return SDL_SetError("Could not allocate haptic storage");
}
Expand All @@ -248,7 +248,6 @@ MacHaptic_MaybeAddDevice( io_object_t device )
/* Set basic device data. */
HIDGetDeviceProduct(device, item->name);
item->dev = device;
item->haptic = NULL;

/* Set usage pages. */
hidProperties = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/haptic/linux/SDL_syshaptic.c
Expand Up @@ -282,11 +282,11 @@ MaybeAddDevice(const char *path)
return -1;
}

item = (SDL_hapticlist_item *) SDL_malloc(sizeof (SDL_hapticlist_item));
item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item));
if (item == NULL) {
return -1;
}
SDL_zerop(item);

item->fname = SDL_strdup(path);
if ( (item->fname == NULL) ) {
SDL_free(item->fname);
Expand Down
4 changes: 1 addition & 3 deletions src/haptic/windows/SDL_syshaptic.c
Expand Up @@ -253,13 +253,11 @@ DirectInputHaptic_MaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance)
return -1; /* not a device we can use. */
}

item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item));
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
return SDL_OutOfMemory();
}

SDL_zerop(item);

item->name = WIN_StringToUTF8(pdidInstance->tszProductName);
if (!item->name) {
SDL_free(item);
Expand Down

0 comments on commit 1084421

Please sign in to comment.