Open
Description
The current pinMode() implementation performs a digitalPinToPort(pin) and then checks the port for NOT_A_PORT but digitalPinToPort() is a program memory table read. It is possible to give an illegal pin number.
Possible correction is:
void pinMode(uint8_t pin, uint8_t mode)
{
if (pin >= NUM_DIGITAL_PINS) return;
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *reg, *out;
...
}
Replacing the port check with a pin number check (first).
Cheers!
Metadata
Metadata
Assignees
Labels
No labels