Skip to content

Commit

Permalink
sdk: Handle carefully when setting bool variable
Browse files Browse the repository at this point in the history
On Windows I found the bool variable to be of size 1 byte. However the
adsd3500_read_cmd() will read 2 bytes. This caused a write outside the
memory area allocated for the bool. In my case the variable was
allocated on stack wich triggered a runtime error when
adsd3500_read_cmd() attempted to write outside the bool variable.

Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jun 28, 2023
1 parent c406f88 commit 1ce2e2c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sdk/src/cameras/itof-camera/camera_itof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1878,9 +1878,11 @@ aditof::Status CameraItof::adsd3500SetJBLFfilterEnableState(bool enable) {
return m_depthSensor->adsd3500_write_cmd(0x0013, enable ? 1 : 0);
}
aditof::Status CameraItof::adsd3500GetJBLFfilterEnableState(bool &enabled) {
enabled = 0;
return m_depthSensor->adsd3500_read_cmd(
0x0017, reinterpret_cast<uint16_t *>(&enabled));
int intEnabled = 0;
aditof::Status status = m_depthSensor->adsd3500_read_cmd(
0x0017, reinterpret_cast<uint16_t *>(&intEnabled));
enabled = !!intEnabled;
return status;
}

aditof::Status CameraItof::adsd3500SetJBLFfilterSize(int size) {
Expand Down

0 comments on commit 1ce2e2c

Please sign in to comment.