{"push_id":1004932791,"size":1,"distinct_size":1,"ref":"refs/heads/patch-3","head":"303a5dc8d995e64ff504cff0b23ab9e884a67fca","before":"244b20b7ccffde82dfcda9ef9ac0a7f2cc1ca3bd","commits":[{"sha":"303a5dc8d995e64ff504cff0b23ab9e884a67fca","author":{"email":"3d2d72faab421e1f4a43a3aa0bb4a4f99e631be4@users.noreply.github.com","name":"cousteau"},"message":"Check for valid pin properly (fixes #4605)\n\nFix for `pinMode()`, `digitalWrite()`, `digitalRead()` (issue #4605).\r\nCurrent behavior: look up pin number in `digital_pin_to_port_PGM[]` and then check if it returned `NOT_A_PIN`.  Causes undefined behavior if provided `pin` number is out of the range of `digital_pin_to_port_PGM[]`.\r\nProposed behavior (from issue #4605): check if `pin` is within the valid range of `digital_pin_to_port_PGM[]`, and THEN look it up.\r\n\r\nAdditionally, remove second check for `port` not being `NOT_A_PIN` (which was useful for boards where the pin numbering skips some numbers).  This can still be achieved by making `bit = digitalPinToBitMask(pin)` be 0 for invalid pins, which causes further bitwise operations such as `*reg &= ~bit;` and `*out |= bit;` to not actually modify the value of the register.  (This removal makes the operation complete a bit faster for valid pins and slower for invalid pins, which I think is a good trade; plus it saves binary size.)","distinct":true,"url":"https://api.github.com/repos/cousteaulecommandant/Arduino/commits/303a5dc8d995e64ff504cff0b23ab9e884a67fca"}]}