include/vcl/opengl/OpenGLHelper.hxx  |   23 ++++++++++++++++++++-
 sd/qa/unit/data/ppt/pass/hang-18.ppt |binary
 sd/source/filter/ppt/propread.cxx    |   25 +++++++++++++++++------
 vcl/source/opengl/OpenGLContext.cxx  |    2 +
 vcl/source/opengl/OpenGLHelper.cxx   |   38 +++++++++++++++++++++++++++++++++++
 5 files changed, 81 insertions(+), 7 deletions(-)

New commits:
commit 7d50c8250c7fb916137c9e687ee0ceed7d96758d
Author: Caolán McNamara <caol...@redhat.com>
Date:   Fri Aug 28 09:15:04 2015 +0100

    clip strings to max available size
    
    Change-Id: Icc1378c9c27b9b6d229bcffc6a63017f82be70d4
    (cherry picked from commit 580d3837b26f09ed02fe3583de40fa045a3fde0f)
    Reviewed-on: https://gerrit.libreoffice.org/18100
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Tested-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/sd/qa/unit/data/ppt/pass/hang-18.ppt 
b/sd/qa/unit/data/ppt/pass/hang-18.ppt
new file mode 100644
index 0000000..3b3e9f7
Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-18.ppt differ
diff --git a/sd/source/filter/ppt/propread.cxx 
b/sd/source/filter/ppt/propread.cxx
index 374ecbb..75a4bcc 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -73,7 +73,7 @@ static sal_Int32 lcl_getMaxSafeStrLen(sal_uInt32 nSize)
 
 bool PropItem::Read( OUString& rString, sal_uInt32 nStringType, bool bAlign )
 {
-    sal_uInt32  i, nItemSize, nType, nItemPos;
+    sal_uInt32 nType, nItemPos;
     bool    bRetValue = false;
 
     nItemPos = Tell();
@@ -86,8 +86,8 @@ bool PropItem::Read( OUString& rString, sal_uInt32 
nStringType, bool bAlign )
     else
         nType = nStringType & VT_TYPEMASK;
 
-    nItemSize = 0; // Initialize in case stream fails.
-    ReadUInt32( nItemSize );
+    sal_uInt32 nItemSize(0); // Initialize in case stream fails.
+    ReadUInt32(nItemSize);
 
     switch( nType )
     {
@@ -95,6 +95,12 @@ bool PropItem::Read( OUString& rString, sal_uInt32 
nStringType, bool bAlign )
         {
             if ( nItemSize )
             {
+                auto nMaxSizePossible = remainingSize();
+                if (nItemSize > nMaxSizePossible)
+                {
+                    SAL_WARN("sd.filter", "String of Len " << nItemSize << " 
claimed, only " << nMaxSizePossible << " possible");
+                    nItemSize = nMaxSizePossible;
+                }
                 try
                 {
                     sal_Char* pString = new sal_Char[ nItemSize ];
@@ -104,7 +110,7 @@ bool PropItem::Read( OUString& rString, sal_uInt32 
nStringType, bool bAlign )
                         if ( nItemSize > 1 )
                         {
                             sal_Unicode* pWString = 
reinterpret_cast<sal_Unicode*>(pString);
-                            for ( i = 0; i < nItemSize; i++ )
+                            for (sal_uInt32 i = 0; i < nItemSize; ++i)
                                 ReadUInt16( pWString[ i ] );
                             rString = OUString(pWString, 
lcl_getMaxSafeStrLen(nItemSize));
                         }
@@ -140,12 +146,19 @@ bool PropItem::Read( OUString& rString, sal_uInt32 
nStringType, bool bAlign )
         {
             if ( nItemSize )
             {
+                auto nMaxSizePossible = remainingSize() / sizeof(sal_Unicode);
+                if (nItemSize > nMaxSizePossible)
+                {
+                    SAL_WARN("sd.filter", "String of Len " << nItemSize << " 
claimed, only " << nMaxSizePossible << " possible");
+                    nItemSize = nMaxSizePossible;
+                }
+
                 try
                 {
                     sal_Unicode* pString = new sal_Unicode[ nItemSize ];
-                    for ( i = 0; i < nItemSize; i++ )
+                    for (sal_uInt32 i = 0; i < nItemSize; ++i)
                         ReadUInt16( pString[ i ] );
-                    if ( pString[ i - 1 ] == 0 )
+                    if ( pString[ nItemSize - 1 ] == 0 )
                     {
                         if ( (sal_uInt16)nItemSize > 1 )
                             rString = OUString(pString, 
lcl_getMaxSafeStrLen(nItemSize));
commit c04099922c2fb177dd310b7aefe5c0b7d3a40fbf
Author: Michael Meeks <michael.me...@collabora.com>
Date:   Fri Aug 28 11:28:13 2015 +0100

    tdf#93529 - add glDebugMessageInsert wrappers to help with API tracing.
    
    Change-Id: Icf75e0e477be1b2bbbe5095aee33e681d212be0b
    Reviewed-on: https://gerrit.libreoffice.org/18103
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>

diff --git a/include/vcl/opengl/OpenGLHelper.hxx 
b/include/vcl/opengl/OpenGLHelper.hxx
index 95c23c8..f2fb214 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -11,6 +11,7 @@
 #define INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
 
 #include <GL/glew.h>
+#include <sal/log.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/bitmapex.hxx>
 
@@ -22,6 +23,18 @@
 #  include <postx.h>
 #endif
 
+/// Helper to do a SAL_INFO as well as a GL log.
+#if OSL_DEBUG_LEVEL > 0
+#  define VCL_GL_INFO(area,stream)          \
+    do {                                    \
+        ::std::ostringstream detail_stream; \
+        detail_stream << stream;            \
+        OpenGLHelper::debugMsgStream((area),detail_stream); \
+    } while (0)
+#else
+#  define VCL_GL_INFO(area,stream)
+#endif
+
 class VCL_DLLPUBLIC OpenGLHelper
 {
 public:
@@ -48,15 +61,23 @@ public:
     static void createFramebuffer(long nWidth, long nHeight, GLuint& 
nFramebufferId,
             GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId, bool 
bRenderbuffer = true);
 
-    // Get OpenGL version (needs a context)
+    /// Get OpenGL version (needs a context)
     static float getGLVersion();
 
     static void checkGLError(const char* aFile, size_t nLine);
 
     /**
+     * Insert a glDebugMessage into the queue - helpful for debugging
+     * with apitrace to annotate the output and correlate it with code.
+     */
+    static void debugMsgPrint(const char *pArea, const char *pFormat, ...);
+    static void debugMsgStream(const char *pArea, std::ostringstream const 
&pStream);
+
+    /**
      * checks if the device/driver pair is on our OpenGL blacklist
      */
     static bool isDeviceBlacklisted();
+
     /**
      * checks if the system supports all features that are necessary for the 
OpenGL VCL support
      */
diff --git a/vcl/source/opengl/OpenGLContext.cxx 
b/vcl/source/opengl/OpenGLContext.cxx
index e76002c..c703c64 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1065,6 +1065,8 @@ bool OpenGLContext::InitGLEW()
         }
     }
 
+    // Test hooks for inserting tracing messages into the stream
+    VCL_GL_INFO("vcl.opengl", "LibreOffice GLContext initialized: " << this);
 #endif
 
     SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----end");
diff --git a/vcl/source/opengl/OpenGLHelper.cxx 
b/vcl/source/opengl/OpenGLHelper.cxx
index daa2af0..f255b3a 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/util/XFlushable.hpp>
 #include <com/sun/star/configuration/theDefaultProvider.hpp>
 
+#include <stdarg.h>
 #include <vector>
 
 #include "opengl/zone.hxx"
@@ -623,6 +624,43 @@ bool OpenGLHelper::isVCLOpenGLEnabled()
     return bRet;
 }
 
+void OpenGLHelper::debugMsgStream(const char *pArea, std::ostringstream const 
&pStream)
+{
+    debugMsgPrint(pArea, "%s", pStream.str().c_str());
+}
+
+void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...)
+{
+    va_list aArgs;
+    va_start (aArgs, pFormat);
+
+    char pStr[1024];
+#ifdef _WIN32
+#define vsnprintf _vsnprintf
+#endif
+    vsnprintf(pStr, sizeof(pStr), pFormat, aArgs);
+    pStr[sizeof(pStr)-1] = '\0';
+
+    SAL_INFO(pArea, pStr);
+
+    OpenGLZone aZone;
+
+    if (GLEW_KHR_debug)
+        glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
+                             GL_DEBUG_TYPE_OTHER,
+                             1, // one[sic] id is as good as another ?
+                             // GL_DEBUG_SEVERITY_NOTIFICATION for >= GL4.3 ?
+                             GL_DEBUG_SEVERITY_LOW,
+                             strlen(pStr), pStr);
+    else if (GLEW_AMD_debug_output)
+        glDebugMessageInsertAMD(GL_DEBUG_CATEGORY_APPLICATION_AMD,
+                                GL_DEBUG_SEVERITY_LOW_AMD,
+                                1, // one[sic] id is as good as another ?
+                                strlen(pStr), pStr);
+
+    va_end (aArgs);
+}
+
 #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && 
!defined(LIBO_HEADLESS)
 
 bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& 
rVI)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to