From fa8a4b44497cfd3dd35eec393b65288bee90be40 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 8 Jul 2019 15:39:11 +0200 Subject: Fix Buffer memory leak when using move-assignment --- src/Buffer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 002c1eb..ab50f1a 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -97,6 +97,9 @@ Buffer& Buffer::operator=(Buffer&& other) if (&other != this) { m_len = other.m_len; m_capacity = other.m_capacity; + if (m_data != nullptr) { + free(m_data); + } m_data = other.m_data; other.m_len = 0; -- cgit v1.2.3