Skip to content

Commit

Permalink
USB: make dev_index u32 for simpler check if it is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
jackun committed Dec 23, 2020
1 parent 17cbb83 commit 91d4c4a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pcsx2/USB/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ typedef struct
struct usb_packet
{
USBEndpoint ep; //usb packet endpoint
int dev_index;
int data_size;
u32 dev_index;
u32 data_size;
} usb_packet;
} USBfreezeData;

Expand Down Expand Up @@ -461,9 +461,9 @@ s32 USBfreeze(int mode, freezeData* data)
ptr += usbd.device[i].size;
}

int dev_index = usbd.usb_packet.dev_index;
u32 dev_index = usbd.usb_packet.dev_index;

if (usb_device[dev_index])
if (dev_index < countof(usb_device) && usb_device[dev_index])
{
USBPacket* p = &qemu_ohci->usb_packet;
p->actual_length = usbd.usb_packet.data_size;
Expand Down Expand Up @@ -495,10 +495,6 @@ s32 USBfreeze(int mode, freezeData* data)
}
}
}
else
{
return -1;
}

}
//TODO straight copying of structs can break cross-platform/cross-compiler save states 'cause padding 'n' stuff
Expand Down

0 comments on commit 91d4c4a

Please sign in to comment.