summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/dive.c b/core/dive.c
index 89e090165..b4fa22d24 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -227,7 +227,10 @@ struct event *add_event(struct divecomputer *dc, unsigned int time, int type, in
void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int seconds, int idx)
{
/* sanity check so we don't crash */
- if (idx < 0 || idx >= dive->cylinders.nr) {
+ /* FIXME: The planner uses a dummy cylinder one past the official number of cylinders
+ * in the table to mark no-cylinder surface interavals. This is horrendous. Fix ASAP. */
+ //if (idx < 0 || idx >= dive->cylinders.nr) {
+ if (idx < 0 || idx >= dive->cylinders.nr + 1 || idx >= dive->cylinders.allocated) {
report_error("Unknown cylinder index: %d", idx);
return;
}