From 9e74b1b3be096ae6fb937cbf1f382e96a33d8b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 2 Mar 2017 20:40:44 +0000 Subject: [PATCH] readonly SvMemoryStream shouldn't allow resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4cd1969cc961d48f904460371ab0a0f960bdea1e Reviewed-on: https://gerrit.libreoffice.org/34832 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- tools/source/stream/stream.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index d9e99b40522d..fa69f58e31e3 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1830,7 +1830,7 @@ bool SvMemoryStream::AllocateMemory( std::size_t nNewSize ) // (using Bozo algorithm) bool SvMemoryStream::ReAllocateMemory( long nDiff ) { - if (!bOwnsData) + if (!m_isWritable || !bOwnsData) return false; bool bRetVal = false; @@ -1916,6 +1916,12 @@ void* SvMemoryStream::SwitchBuffer() void SvMemoryStream::SetSize(sal_uInt64 const nNewSize) { + if (!m_isWritable) + { + SetError(SVSTREAM_INVALID_HANDLE); + return; + } + long nDiff = (long)nNewSize - (long)nSize; ReAllocateMemory( nDiff ); }