summaryrefslogtreecommitdiffstats
path: root/profile-widget/profilewidget2.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-07-06 14:41:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-07-06 11:23:35 -0700
commit69be1e23f231081e6bad98903c10782faf5104a7 (patch)
treebf8ca85183983f6adebd494c59c80663cb33f48c /profile-widget/profilewidget2.cpp
parent5e9ffe30053454ef9d058c7e7d41f55508cb66d7 (diff)
downloadsubsurface-69be1e23f231081e6bad98903c10782faf5104a7.tar.gz
Cleanup: fix memory management of the plot data
There was a global variable last_pi_entry_new, which stored the recently allocated plot data. This was freed when new plot data was generated. A very scary proposition: You can never have two plot datas at the same time! But exactly that happens when you export for example subtitles. The only reason why this didn't lead to very crazy behavior is that at least on my Linux machine, the calloc() call would just return the previously freed memory. Fix this mess by removing the global variable and freeing the data in the callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/profilewidget2.cpp')
-rw-r--r--profile-widget/profilewidget2.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index f117dc450..f377eeb8e 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -636,6 +636,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
* shown.
*/
+ free_plot_info_data(&plotInfo);
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
#ifndef SUBSURFACE_MOBILE
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state);