Fix some crashes by checking pointers before deref
This commit is contained in:
@@ -144,6 +144,8 @@ int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
|
||||
int i = 0;
|
||||
|
||||
for (; i < wiimotes; ++i) {
|
||||
if (!wm[i])
|
||||
continue;
|
||||
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED))
|
||||
++connected;
|
||||
}
|
||||
|
||||
@@ -505,8 +505,12 @@ void wiiuse_status(struct wiimote_t* wm) {
|
||||
*/
|
||||
struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid) {
|
||||
int i = 0;
|
||||
if (!wm)
|
||||
return NULL;
|
||||
|
||||
for (; i < wiimotes; ++i) {
|
||||
if (!wm[i])
|
||||
continue;
|
||||
if (wm[i]->unid == unid)
|
||||
return wm[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user