summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-03-26 13:56:11 +0100
committerTomaž Vajngerl <quikee@gmail.com>2019-03-28 15:43:02 +0100
commite299dd1dfbd67d0c662ca63df4a6eb43ea590a17 (patch)
treecac8ffe21da98655e846f57614d5d03147d53c18 /vcl/opengl
parentdf82c812e6dbb08837816ef9868bf24b3767ca1a (diff)
make OpenGLSalBitmap deallocate user data properly
In OpenGLSalBitmap::AcquireBuffer(), if ReadTexture() failed, then the data from AllocateUserData() didn't get deallocated and a next call to OpenGLSalBitmap::AcquireBuffer() skipped the whole block because it assumed the data was valid. Triggered while fixing tdf#116888. Change-Id: Ibfe5c42d6b18748ca649d6b4242ef268c1b13a71 Reviewed-on: https://gerrit.libreoffice.org/69746 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/salbmp.cxx17
1 files changed, 13 insertions, 4 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index d8a8454ca4e7..27d2e19e2734 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -258,7 +258,7 @@ void OpenGLSalBitmap::Destroy()
VCL_GL_INFO("Destroy OpenGLSalBitmap texture:" << maTexture.Id());
maTexture = OpenGLTexture();
- mpUserBuffer.reset();
+ DeallocateUserData();
}
bool OpenGLSalBitmap::AllocateUserData()
@@ -292,8 +292,7 @@ bool OpenGLSalBitmap::AllocateUserData()
if (!alloc)
{
SAL_WARN("vcl.opengl", "bad alloc " << mnBytesPerRow << "x" << mnHeight);
- mpUserBuffer.reset();
- mnBytesPerRow = 0;
+ DeallocateUserData();
}
#ifdef DBG_UTIL
else
@@ -306,6 +305,12 @@ bool OpenGLSalBitmap::AllocateUserData()
return mpUserBuffer != nullptr;
}
+void OpenGLSalBitmap::DeallocateUserData()
+{
+ mpUserBuffer.reset();
+ mnBytesPerRow = 0;
+}
+
namespace {
class ImplPixelFormat
@@ -763,7 +768,10 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
if( !AllocateUserData() )
return nullptr;
if( maTexture && !ReadTexture() )
+ {
+ DeallocateUserData();
return nullptr;
+ }
}
}
@@ -870,6 +878,7 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ )
if( !AllocateUserData() || !ReadTexture() )
{
rBitmap.ReleaseBuffer( pBuffer, false );
+ DeallocateUserData();
return false;
}
}
@@ -955,7 +964,7 @@ bool OpenGLSalBitmap::ConvertToGreyscale()
maPalette = Bitmap::GetGreyPalette(256);
// AllocateUserData will handle the rest.
- mpUserBuffer.reset();
+ DeallocateUserData();
mbDirtyTexture = false;
CHECK_GL_ERROR();