Cleanup: prevent potential out of bounds write
Since we cannot store tanks / gases past MAX_CYLINDERS (currently 20), there is no point in analyzing those data. Coverity CID 208339 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
efb2640fc7
commit
0e94c21a55
@ -115,7 +115,7 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||
#endif
|
||||
bool no_volume = true;
|
||||
|
||||
for (i = 0; i < ngases || i < ntanks; i++) {
|
||||
for (i = 0; i < MAX_CYLINDERS && (i < ngases || i < ntanks); i++) {
|
||||
if (i < ngases) {
|
||||
dc_gasmix_t gasmix = { 0 };
|
||||
int o2, he;
|
||||
@ -124,10 +124,7 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED)
|
||||
return rc;
|
||||
|
||||
if (i >= MAX_CYLINDERS)
|
||||
continue;
|
||||
|
||||
o2 = lrint(gasmix.oxygen * 1000);
|
||||
o2 = lrint(gasmix.oxygen * 1000);
|
||||
he = lrint(gasmix.helium * 1000);
|
||||
|
||||
/* Ignore bogus data - libdivecomputer does some crazy stuff */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user