ms-iot / lightning

MIT License
16 stars 20 forks source link

analogRead - case where ioPin is not initialized on invalid pin value. #24

Closed ooeygui closed 8 years ago

ooeygui commented 8 years ago

in analogRead, ioPin is not initialized to a value. in the board switch statement: case BoardPinsClass::BOARD_TYPE::MBM_BARE: case BoardPinsClass::BOARD_TYPE::PI2_BARE: // Translate the pin number to a fake pin number. if (pin < A0) { ioPin = A0 + pin; } break; default: ThrowError(hr, "Unrecognized board type: 0x%08x", board); }

// Perform the read.
hr = g_adc.readValue(ioPin, value, bits);

if (FAILED(hr))
{
    ThrowError(hr, "Error performing analogRead on pin: %d, Error: 0x%08x", pin, hr);
}

this means if I accidentally pass a bad pin, there is no trap and it falls through and used without being initialized.

ooeygui commented 8 years ago

Turns out that this happens on A0.