Cleanup: Fix Problems Raised by Coverity Scan.

Opportunistically fix some problems newly raised by a recent Coverity
scan.

Not touching any of the string memory allocation issues as this is being
handled by the move towards C++ strings.

Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
Michael Keller 2024-03-13 13:11:34 +13:00 committed by Michael Keller
parent 3229d1e3a1
commit e6ff3f7537
3 changed files with 11 additions and 10 deletions

View file

@ -470,7 +470,7 @@ static bool has_unknown_used_cylinders(const struct dive *dive, const struct div
/* We know about the explicit first cylinder (or first) */
idx = explicit_first_cylinder(dive, dc);
if (used_and_unknown[idx]) {
if (idx >= 0 && used_and_unknown[idx]) {
used_and_unknown[idx] = false;
num--;
}