Skip to content

Commit

Permalink
Modifed checks of array dimensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lars2015 committed Jul 29, 2024
1 parent 2df1402 commit 7b1e9fb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/atm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int main(
}

/* Set particle counter... */
if ((++atm->np) >= NP)
if ((++atm->np) > NP)
ERRMSG("Too many particles!");
}

Expand Down
2 changes: 1 addition & 1 deletion src/atm_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int main(
atm2->lat[atm2->np] = atm->lat[ip];
for (int iq = 0; iq < ctl.nq; iq++)
atm2->q[iq][atm2->np] = atm->q[iq][ip];
if ((++atm2->np) >= NP)
if ((++atm2->np) > NP)
ERRMSG("Too many air parcels!");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/atm_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int main(
atm2->q[ctl.qnt_idx][atm2->np] = atm2->np;

/* Increment particle counter... */
if ((++atm2->np) >= NP)
if ((++atm2->np) > NP)
ERRMSG("Too many air parcels!");
}

Expand Down
4 changes: 2 additions & 2 deletions src/mptrac.c
Original file line number Diff line number Diff line change
Expand Up @@ -3033,7 +3033,7 @@ void module_isosurf_init(
while (fgets(line, LEN, in))
if (sscanf(line, "%lg %lg", &(cache->iso_ts[cache->iso_n]),
&(cache->iso_ps[cache->iso_n])) == 2)
if ((++cache->iso_n) >= NP)
if ((++cache->iso_n) > NP)
ERRMSG("Too many data points!");

/* Check number of points... */
Expand Down Expand Up @@ -4239,7 +4239,7 @@ int read_atm_asc(
atm->p[atm->np] = P(atm->p[atm->np]);

/* Increment data point counter... */
if ((++atm->np) >= NP)
if ((++atm->np) > NP)
ERRMSG("Too many data points!");
}

Expand Down

0 comments on commit 7b1e9fb

Please sign in to comment.