Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions wiiuse/io_wii.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ static s32 __wiiuse_disconnected(void *arg,struct bte_pcb *pcb,u8 err)

bte_free(wml->sock);
wml->sock = NULL;
if(wm->sock==wml->sock)
wm->sock = NULL;
return ERR_OK;
}

Expand Down
9 changes: 8 additions & 1 deletion wiiuse/wiiuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ void wiiuse_cleanup(struct wiimote_t **wm, int wiimotes)
wm[i]->queue_buffer = NULL;
}

//should normally have been free'd by other code, but just in case it isnt
//to remove?
if (wm[i]->sock) {
bte_free(wm[i]->sock);
wm[i]->sock = NULL;
Expand All @@ -77,6 +79,9 @@ void wiiuse_cleanup(struct wiimote_t **wm, int wiimotes)
}
}

//clear internal pointer too
if (wm == __wm)
__wm = NULL;
free(wm);
}

Expand All @@ -98,8 +103,10 @@ struct wiimote_t** wiiuse_init(int wiimotes, wii_event_cb event_cb) {
}

for (i = 0; i < wiimotes; ++i) {
if(!__wm[i])
if (!__wm[i]) {
__wm[i] = malloc(sizeof(struct wiimote_t));
if (!__wm[i]) return NULL; // Lets try to avoid crashing if OOM
}

memset(__wm[i], 0, sizeof(struct wiimote_t));
__wm[i]->unid = i;
Expand Down
Loading