Prevent an infinite loop.

When the number of parameters is zero, there are no sample values, and
the offset variable is never increased. The result is an infinite loop.
In practice this shouldn't happen because there should always be at
least one sample value (e.g. depth). But if a new data format is
available, which is not yet supported by the parser, we might be trying
to interpret the wrong byte.
This commit is contained in:
Jef Driesen 2013-04-18 08:11:51 +02:00
parent 3ce237eee4
commit 8f3eb48bfb

View File

@ -314,7 +314,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
// Number of parameters in the configuration data.
unsigned int nparams = data[config];
if (nparams > MAXPARAMS)
if (nparams == 0 || nparams > MAXPARAMS)
return DC_STATUS_DATAFORMAT;
// Available divisor values.