Fix possible memory leaks in hidpad_ps3_connect, hidpad_ps4_connect, and hidpad_wii_connect

This commit is contained in:
Lioncash 2014-10-13 17:39:14 -04:00
parent c5512dbd5b
commit 316870201f
3 changed files with 21 additions and 3 deletions

View File

@ -60,9 +60,15 @@ static void* hidpad_ps3_connect(void *connect_data, uint32_t slot, send_control_
struct hidpad_ps3_data* device = (struct hidpad_ps3_data*)
calloc(1, sizeof(struct hidpad_ps3_data));
if (!device || !connection)
if (!device)
return NULL;
if (!connection)
{
free(device);
return NULL;
}
device->connection = connection;
device->slot = slot;
device->send_control = ptr;

View File

@ -54,9 +54,15 @@ static void* hidpad_ps4_connect(void *connect_data, uint32_t slot, send_control_
struct hidpad_ps4_data* device = (struct hidpad_ps4_data*)
calloc(1, sizeof(struct hidpad_ps4_data));
if (!device || !connection)
if (!device)
return NULL;
if (!connection)
{
free(device);
return NULL;
}
device->connection = connection;
device->slot = slot;
device->send_control = ptr;

View File

@ -463,9 +463,15 @@ static void* hidpad_wii_connect(void *data, uint32_t slot,
struct wiimote_t *device = (struct wiimote_t*)
calloc(1, sizeof(struct wiimote_t));
if (!device || !connection)
if (!device)
return NULL;
if (!connection)
{
free(device);
return NULL;
}
device->connection = connection;
device->unid = slot;
device->state = WIIMOTE_STATE_CONNECTED;