From 16b31985c3245d5cb3be26f3cc0aa06bc6acb139 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 20 Jul 2021 07:45:31 +0200 Subject: cleanup: replace membuffer by membufferpp in C-code Thus, the membuffer data is automatically freed when going out of scope - one thing less to worry about. This fixes one use-after-free bug in uploadDiveLogsDE.cpp and one extremely questionable practice in divetooltipitem.cpp: The membuffer was a shared instance across all instances of the DiveToolTipItem. Remves unnecessary #include directives in files that didn't even use membuffer. Signed-off-by: Berthold Stoeger --- profile-widget/divetooltipitem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp index 5cc6eecad..3a0a4de58 100644 --- a/profile-widget/divetooltipitem.cpp +++ b/profile-widget/divetooltipitem.cpp @@ -221,7 +221,7 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis) void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner) { - static struct membuffer mb = {}; + struct membufferpp mb; if(refreshTime.elapsed() < 40) return; @@ -232,7 +232,6 @@ void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner) lastTime = time; clear(); - mb.len = 0; int idx = get_plot_details_new(d, &pInfo, time, &mb); tissues.fill(); -- cgit v1.2.3-70-g09d2