Preliminary Checks
Description
ZEDController::getSensorsDataBatch() has two bugs that cause a segfault on the first call.
Steps to Reproduce
Bug 1: memset on uninitialized pointer
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L640
// ZEDController.cpp line 640
memset(*data, 0, sizeof(SL_SensorsData) * size);
data is an output parameter (SL_SensorsData**). *data is uninitialized — writes to garbage address → SIGSEGV.
Bug 2: Wrong array indexing
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L645
// ZEDController.cpp line 645
SL_SensorsData* sensorData = data[i];
data is a pointer to one pointer, not an array of pointers. data[i] for i > 0 reads out of bounds.
Additional: inner loop variable shadowing
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L642
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L674
The covariance copy loop at line 674 reuses the outer loop variable i:
for (int i = 0; i < size; i++) { // outer
for (int i = 0; i < 9; i++) { ... } // shadows outer i
}
Expected Result
no crashes
Actual Result
SIGSEGV
ZED Camera model
ZED
Environment
ZED SDK 5.3.1, zed-c-api main (751d26f), Jetson Orin NX, JetPack 6.2.2
Anything else?
No response
Preliminary Checks
Description
ZEDController::getSensorsDataBatch()has two bugs that cause a segfault on the first call.Steps to Reproduce
Bug 1:
memseton uninitialized pointerhttps://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L640
datais an output parameter (SL_SensorsData**).*datais uninitialized — writes to garbage address → SIGSEGV.Bug 2: Wrong array indexing
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L645
// ZEDController.cpp line 645 SL_SensorsData* sensorData = data[i];datais a pointer to one pointer, not an array of pointers.data[i]fori > 0reads out of bounds.Additional: inner loop variable shadowing
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L642
https://github.com/stereolabs/zed-c-api/blob/main/src/ZEDController.cpp#L674
The covariance copy loop at line 674 reuses the outer loop variable
i:Expected Result
no crashes
Actual Result
SIGSEGV
ZED Camera model
ZED
Environment
Anything else?
No response