Skip to content

Commit

Permalink
Do not delete String::endZero
Browse files Browse the repository at this point in the history
```
[ 59%] Building CXX object Source/Urho3D/CMakeFiles/Urho3D.dir/Container/Str.cpp.o
In file included from U3D/Source/Urho3D/Precompiled.h:31:
In destructor ‘Urho3D::String::~String()’,
    inlined from ‘Urho3D::String Urho3D::String::Substring(unsigned int) const’ at U3D/Source/Urho3D/Container/Str.cpp:499:5:
U3D/Source/Urho3D/Container/Str.h:169:22: warning: ‘void operator delete [](void*)’ called on unallocated object ‘Urho3D::String::endZero’ [-Wfree-nonheap-object]
  169 |             delete[] buffer_;
      |                      ^~~~~~~
U3D/Source/Urho3D/Container/Str.cpp: In member function ‘Urho3D::String Urho3D::String::Substring(unsigned int) const’:
U3D/Source/Urho3D/Container/Str.cpp:38:6: note: declared here
   38 | char String::endZero = 0;
      |      ^~~~~~
```
  • Loading branch information
SirNate0 authored Jun 5, 2023
1 parent 21f1df6 commit d69a08d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/Urho3D/Container/Str.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class URHO3D_API String
/// Destruct.
~String()
{
if (capacity_)
if (capacity_ && buffer_ != &endZero)
delete[] buffer_;
}

Expand Down

0 comments on commit d69a08d

Please sign in to comment.