From 69be1e23f231081e6bad98903c10782faf5104a7 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 6 Jul 2019 14:41:09 +0200 Subject: 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 --- profile-widget/profilewidget2.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'profile-widget') 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); -- cgit v1.2.3-70-g09d2