From 93b65aad36a68dea2984e0224ffbce826aebb97d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 30 Nov 2015 22:44:48 -0800 Subject: [PATCH] DigitalInput: Don't crash on Get() of invalid channel. The constructor sets m_channel to UINT32_MAX and reports an error if the channel index is out of range (or CheckDigitalChannel fails for some other reason). A Get() following this would result in a crash because it wasn't checking StatusIsFatal(). The new behavior now checks StatusIsFatal() and simply returns false. Change-Id: I15529401294e4ccd1e09df834e02cca367fab67c --- wpilibc/Athena/src/DigitalInput.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wpilibc/Athena/src/DigitalInput.cpp b/wpilibc/Athena/src/DigitalInput.cpp index e525cc058f..38c29b7a7d 100644 --- a/wpilibc/Athena/src/DigitalInput.cpp +++ b/wpilibc/Athena/src/DigitalInput.cpp @@ -62,6 +62,7 @@ DigitalInput::~DigitalInput() { * Retrieve the value of a single digital input channel from the FPGA. */ bool DigitalInput::Get() const { + if (StatusIsFatal()) return false; int32_t status = 0; bool value = getDIO(m_digital_ports[m_channel], &status); wpi_setErrorWithContext(status, getHALErrorMessage(status));