diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-07-20 07:45:31 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-07-23 11:22:43 -0700 |
commit | 16b31985c3245d5cb3be26f3cc0aa06bc6acb139 (patch) | |
tree | 972684866d5ec71781fbf91f990bea83a654ecad /backend-shared | |
parent | f142e9a9c6ba493c09a282544da8715b3656648e (diff) | |
download | subsurface-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 'backend-shared')
-rw-r--r-- | backend-shared/exportfuncs.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/backend-shared/exportfuncs.cpp b/backend-shared/exportfuncs.cpp index 7f15886db..8bcdfdcb0 100644 --- a/backend-shared/exportfuncs.cpp +++ b/backend-shared/exportfuncs.cpp @@ -65,7 +65,7 @@ void export_TeX(const char *filename, bool selected_only, bool plain, ExportCall int i; bool need_pagebreak = false; - struct membuffer buf = {}; + struct membufferpp buf; if (plain) { ssrf = ""; @@ -253,7 +253,6 @@ void export_TeX(const char *filename, bool selected_only, bool plain, ExportCall flush_buffer(&buf, f); /*check for writing errors? */ fclose(f); } - free_buffer(&buf); cb.setProgress(1000); } @@ -265,7 +264,7 @@ void export_depths(const char *filename, bool selected_only) int i; const char *unit = NULL; - struct membuffer buf = {}; + struct membufferpp buf; for_each_dive (i, dive) { if (selected_only && !dive->selected) @@ -291,7 +290,6 @@ void export_depths(const char *filename, bool selected_only) flush_buffer(&buf, f); /*check for writing errors? */ fclose(f); } - free_buffer(&buf); } #endif /* ! SUBSURFACE_MOBILE */ |