summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/TabDivePhotos.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-07-20 07:45:31 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-07-23 11:22:43 -0700
commit16b31985c3245d5cb3be26f3cc0aa06bc6acb139 (patch)
tree972684866d5ec71781fbf91f990bea83a654ecad /desktop-widgets/tab-widgets/TabDivePhotos.cpp
parentf142e9a9c6ba493c09a282544da8715b3656648e (diff)
downloadsubsurface-16b31985c3245d5cb3be26f3cc0aa06bc6acb139.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDivePhotos.cpp')
-rw-r--r--desktop-widgets/tab-widgets/TabDivePhotos.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.cpp b/desktop-widgets/tab-widgets/TabDivePhotos.cpp
index 03351184f..87203c74c 100644
--- a/desktop-widgets/tab-widgets/TabDivePhotos.cpp
+++ b/desktop-widgets/tab-widgets/TabDivePhotos.cpp
@@ -128,13 +128,12 @@ void TabDivePhotos::saveSubtitles()
// Only videos have non-zero duration
if (!duration)
continue;
- struct membuffer b = { 0 };
+ struct membufferpp b;
save_subtitles_buffer(&b, current_dive, offset, duration);
- char *data = detach_cstring(&b);
+ const char *data = mb_cstring(&b);
subtitlefile.open(QIODevice::WriteOnly);
subtitlefile.write(data, strlen(data));
subtitlefile.close();
- free(data);
}
}
}