summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/salbmp.cxx29
1 files changed, 28 insertions, 1 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 0896fd1a8070..61d7575b7448 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -36,6 +36,10 @@
#include "opengl/FixedTextureAtlas.hxx"
+#if OSL_DEBUG_LEVEL > 0
+# define CANARY "tex-canary"
+#endif
+
namespace
{
@@ -145,6 +149,9 @@ bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long
mbDirtyTexture = false;
VCL_GL_INFO( "Created texture " << maTexture.Id() );
+ assert(mnWidth == maTexture.GetWidth() &&
+ mnHeight == maTexture.GetHeight());
+
return true;
}
@@ -256,7 +263,15 @@ bool OpenGLSalBitmap::AllocateUserData()
{
try
{
- maUserBuffer.reset( new sal_uInt8[static_cast<sal_uInt32>(mnBytesPerRow) * mnHeight] );
+ size_t nToAllocate = static_cast<sal_uInt32>(mnBytesPerRow) * mnHeight;
+#if OSL_DEBUG_LEVEL > 0
+ nToAllocate += sizeof(CANARY);
+#endif
+ maUserBuffer.reset( new sal_uInt8[nToAllocate] );
+#if OSL_DEBUG_LEVEL > 0
+ memcpy(maUserBuffer.get() + nToAllocate - sizeof(CANARY),
+ CANARY, sizeof(CANARY));
+#endif
alloc = true;
}
catch (const std::bad_alloc &) {}
@@ -532,7 +547,19 @@ bool OpenGLSalBitmap::ReadTexture()
{
determineTextureFormat(mnBits, nFormat, nType);
+ // if this fails we can read too much into pData
+ assert(mnWidth == maTexture.GetWidth() &&
+ mnHeight == maTexture.GetHeight());
+
maTexture.Read(nFormat, nType, pData);
+
+#if OSL_DEBUG_LEVEL > 0
+ // If we read over the end of pData we have a real hidden memory
+ // corruption problem !
+ size_t nCanary = static_cast<sal_uInt32>(mnBytesPerRow) * mnHeight;
+ assert(!memcmp(pData + nCanary, CANARY, sizeof (CANARY)));
+#endif
+
mnBufWidth = mnWidth;
mnBufHeight = mnHeight;
return true;