diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-10-22 20:15:47 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-23 19:02:54 +0100 |
commit | 50698a0db4621e34969146f089e019fa93d29dc4 (patch) | |
tree | 018bb290ed1d2c5277ff32d256d2b468991ae9fb /Userland/Libraries | |
parent | 5d865d574a102501bd8a616f01e52e489ce88e6d (diff) | |
download | serenity-50698a0db4621e34969146f089e019fa93d29dc4.zip |
AK: Prevent accidental misuse of BumpAllocator
In particular, we implicitly required that the caller initializes the
returned instances themselves (solved by making
UniformBumpAllocator::allocate call the constructor), and BumpAllocator
itself cannot handle classes that are not trivially deconstructible
(solved by deleting the method).
Co-authored-by: Ali Mohammad Pur <ali.mpfard@gmail.com>
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexMatcher.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Userland/Libraries/LibRegex/RegexMatcher.cpp b/Userland/Libraries/LibRegex/RegexMatcher.cpp index b0c8708bad..dbc5b98cbe 100644 --- a/Userland/Libraries/LibRegex/RegexMatcher.cpp +++ b/Userland/Libraries/LibRegex/RegexMatcher.cpp @@ -333,13 +333,12 @@ public: ALWAYS_INLINE void append(T value) { - auto new_node = m_allocator.allocate(); - VERIFY(new_node); - auto node_ptr = new (new_node) Node { move(value), nullptr, nullptr }; + auto node_ptr = m_allocator.allocate(move(value)); + VERIFY(node_ptr); if (!m_first) { - m_first = new_node; - m_last = new_node; + m_first = node_ptr; + m_last = node_ptr; return; } |