Fix some crashes by checking pointers before deref

This commit is contained in:
Ryan Pavlik
2010-11-11 15:11:27 -06:00
parent 61238e4732
commit 8eef1f89dc
2 changed files with 6 additions and 0 deletions

View File

@@ -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];
}