mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Add some sanity checks
If first sample is not a DC_SAMPLE_TIME, we would have bin dereferencing a null pointer. This might actually never happen, unless we talk to a really weird dc, but this makes the static analyzer happier. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5b61409358
commit
0812d2def2
1 changed files with 7 additions and 0 deletions
|
@ -181,6 +181,13 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
*/
|
||||
sample = dc->samples ? dc->sample+dc->samples-1 : NULL;
|
||||
|
||||
/*
|
||||
* Ok, sanity check.
|
||||
* If first sample is not a DC_SAMPLE_TIME, Allocate a sample for us
|
||||
*/
|
||||
if (sample == NULL && type != DC_SAMPLE_TIME)
|
||||
sample = prepare_sample(dc);
|
||||
|
||||
switch (type) {
|
||||
case DC_SAMPLE_TIME:
|
||||
if (sample) {
|
||||
|
|
Loading…
Add table
Reference in a new issue