Skip to content

Commit 3ee886b

Browse files
thepsrfacchinm
authored andcommitted
Fix array out of bounds in USB core
1 parent f80361f commit 3ee886b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: cores/arduino/USB/USBCore.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,10 @@ uint32_t EndPoints[] =
391391
0,
392392
#endif
393393
};
394+
#define EP_ARRAY_SIZE (sizeof(EndPoints)/sizeof(EndPoints[0]))
394395

395396
void USBDeviceClass::initEndpoints() {
396-
for (uint8_t i = 1; i < sizeof(EndPoints) && EndPoints[i] != 0; i++) {
397+
for (uint8_t i = 1; (i < EP_ARRAY_SIZE) && (EndPoints[i] != 0); i++) {
397398
initEP(i, EndPoints[i]);
398399
}
399400
}

0 commit comments

Comments
 (0)