Commit 86fc2b0
committed
shearwater: fix userdata corruption in predator parser samples loop
shearwater_predator_parser_samples_foreach serves two purposes:
an internal calibration pre-pass called with callback=NULL and a
dc_parser_sensor_calibration_t * as userdata, and normal sample
enumeration called with a real callback and the caller's own userdata.
The guard that restricted calibration writes to the pre-pass checked
only that userdata was non-NULL, so during normal sample enumeration it
cast the caller's userdata pointer to dc_parser_sensor_calibration_t *
and wrote into it. For any CCR dive with internal (non-external) ppo2,
this wrote the value 1 into the first byte of whatever struct the caller
passed, e.g. the low byte of divecomputer::when in Subsurface (a small
timestamp corruption) or a FILE * member in dctool (a crash).
Fix: add !callback to the guard so the internal calibration writes only
happen during the pre-pass (callback == NULL).
Signed-off-by: Michael Keller <github@ike.ch>1 parent c80c4b4 commit 86fc2b0
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1224 | 1224 | | |
1225 | 1225 | | |
1226 | 1226 | | |
1227 | | - | |
| 1227 | + | |
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
| |||
0 commit comments