Skip to content

Commit

Permalink
Prevent deletion of an empty vector
Browse files Browse the repository at this point in the history
  • Loading branch information
efondere committed Jan 23, 2023
1 parent 8a0b609 commit 4c38a89
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ArduinoExtra/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class Vector
*/
~Vector()
{
// prevent deletion of an empty/uninitialized vector
if (m_data == nullptr)
{
return;
}

clear();
::operator delete(m_data, m_capacity * sizeof(T));
}
Expand Down

0 comments on commit 4c38a89

Please sign in to comment.