profile: clear plot_info structure when freeing data

free_plot_info_data() frees the sample and pressure arrays
and accordingly sets the corresponding pointers to NULL.

However, it doesn't clear the element-count and thus leaves
the structure in an inconsistent state.

Clear the whole structure with memset(). I am not a fan of
doing so, but there are existing memset() calls in the
same source file, so let's keep it like that for consistency.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-12-04 16:06:35 +01:00 committed by Dirk Hohndel
parent 564cbc797c
commit 789eb2c620

View file

@ -395,8 +395,7 @@ void free_plot_info_data(struct plot_info *pi)
{
free(pi->entry);
free(pi->pressures);
pi->entry = NULL;
pi->pressures = NULL;
memset(pi, 0, sizeof(*pi));
}
static void populate_plot_entries(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi)