summaryrefslogtreecommitdiff
path: root/asl/tests/format_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/tests/format_tests.cpp')
-rw-r--r--asl/tests/format_tests.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/asl/tests/format_tests.cpp b/asl/tests/format_tests.cpp
index 906fce6..042fcb4 100644
--- a/asl/tests/format_tests.cpp
+++ b/asl/tests/format_tests.cpp
@@ -12,6 +12,11 @@ class StringSink : public asl::Writer
char* m_data{};
public:
+ ~StringSink()
+ {
+ reset();
+ }
+
void write(asl::span<const asl::byte> str) override
{
m_data = reinterpret_cast<char*>(asl::GlobalHeap::realloc(
@@ -28,9 +33,12 @@ public:
void reset()
{
- m_current_len = 0;
- asl::GlobalHeap::dealloc(m_data, asl::layout::array<char>(m_current_len));
- m_data = nullptr;
+ if (m_data != nullptr)
+ {
+ m_current_len = 0;
+ asl::GlobalHeap::dealloc(m_data, asl::layout::array<char>(m_current_len));
+ m_data = nullptr;
+ }
}
};