mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
Handle plot_info->nr <= 0 gracefully
plot_info->nr should always be > 0. If this is not the case, write a message to stderr instead of crashing in add_plot_pressure(). This silences an use-of-uninitialized-variable warning. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0b2d22494c
commit
22dc7b84f0
1 changed files with 4 additions and 0 deletions
|
@ -805,6 +805,10 @@ static void populate_secondary_sensor_data(struct divecomputer *dc, struct plot_
|
||||||
static void add_plot_pressure(struct plot_info *pi, int time, int cyl, pressure_t p)
|
static void add_plot_pressure(struct plot_info *pi, int time, int cyl, pressure_t p)
|
||||||
{
|
{
|
||||||
struct plot_data *entry;
|
struct plot_data *entry;
|
||||||
|
if (pi->nr <= 0) {
|
||||||
|
fprintf(stderr, "add_plot_pressure(): called with pi->nr <= 0\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int i = 0; i < pi->nr; i++) {
|
for (int i = 0; i < pi->nr; i++) {
|
||||||
entry = pi->entry + i;
|
entry = pi->entry + i;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue