From 3114ac110a24250e7bf4a8ef2243b88f45c34237 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Wed, 17 Jan 2024 14:14:33 -0800 Subject: [PATCH] [Glacier] Fix string memory deletion (thanks valgrind)../scripts/qemu.sh --- lib/glacier/string/string.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/glacier/string/string.cpp b/lib/glacier/string/string.cpp index e0a5b67..a2b6db3 100644 --- a/lib/glacier/string/string.cpp +++ b/lib/glacier/string/string.cpp @@ -32,7 +32,7 @@ String::String(const String& other) : String(other.cstr_, other.length_) {} String& String::operator=(const String& other) { if (cstr_) { - delete cstr_; + delete[] cstr_; } length_ = other.length_; cstr_ = new char[length_ + 1]; @@ -51,7 +51,7 @@ String::String(String&& other) : cstr_(other.cstr_), length_(other.length_) { String& String::operator=(String&& other) { if (cstr_) { - delete cstr_; + delete[] cstr_; } cstr_ = other.cstr_; length_ = other.length_; @@ -64,7 +64,7 @@ String& String::operator=(String&& other) { String::~String() { if (cstr_) { - delete cstr_; + delete[] cstr_; } }