From 23ae341869ddb0d1af81ee7a5705b776817afd4c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 Apr 2018 15:40:33 +0200 Subject: assert that we own the data before freeing it Change-Id: I9676da22c00570cd59f2f46b04beb5f1337bbacf Reviewed-on: https://gerrit.libreoffice.org/52887 Tested-by: Jenkins Reviewed-by: Noel Grandin --- tools/source/stream/stream.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 5d6d3e58336b..b48275819739 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1866,7 +1866,12 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff ) void SvMemoryStream::FreeMemory() { - delete[] pBuf; + assert(bOwnsData); + if (bOwnsData) + { + delete[] pBuf; + pBuf = nullptr; + } } void* SvMemoryStream::SwitchBuffer() -- cgit v1.2.3