[Libreoffice-commits] libvisio.git: 2 commits - src/lib
David Tardon
dtardon at redhat.com
Thu Nov 27 12:41:49 PST 2014
src/lib/VSDParser.cpp | 19 +++++++++++++++++--
src/lib/VSDParser.h | 4 ++++
2 files changed, 21 insertions(+), 2 deletions(-)
New commits:
commit 770e649b1b30e2b43e62d00ed06b4ff33f8305e0
Author: David Tardon <dtardon at redhat.com>
Date: Thu Nov 27 21:36:48 2014 +0100
avoid infinite recursion when reading a broken file
Change-Id: Icb292ae4b4c286be52ee81e5d08b43efccb1892d
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 9fe8080..c5c7541 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -26,7 +26,7 @@ libvisio::VSDParser::VSDParser(librevenge::RVNGInputStream *input, librevenge::R
m_currentShapeLevel(0), m_currentShapeID(MINUS_ONE), m_extractStencils(false), m_colours(),
m_isBackgroundPage(false), m_isShapeStarted(false), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0),
m_currentGeometryList(0), m_currentGeomListCount(0), m_fonts(), m_names(), m_namesMapMap(),
- m_currentPageName()
+ m_currentPageName(), m_handledStreams()
{}
libvisio::VSDParser::~VSDParser()
@@ -112,6 +112,7 @@ bool libvisio::VSDParser::parseMain()
Pointer trailerPointer;
readPointer(m_input, trailerPointer);
+ m_handledStreams.insert(trailerPointer.Offset);
bool compressed = ((trailerPointer.Format & 2) == 2);
unsigned shift = 0;
if (compressed)
@@ -131,6 +132,8 @@ bool libvisio::VSDParser::parseMain()
return false;
_handleLevelChange(0);
+ m_handledStreams.clear();
+ m_handledStreams.insert(trailerPointer.Offset);
VSDStyles styles = stylesCollector.getStyleSheets();
@@ -204,6 +207,15 @@ void libvisio::VSDParser::handleStreams(librevenge::RVNGInputStream *input, unsi
if (ptr.Type == 0)
continue;
+ std::set<unsigned>::iterator it = m_handledStreams.find(ptr.Offset);
+ if (it != m_handledStreams.end())
+ {
+ VSD_DEBUG_MSG(("Stream at offset %d has already been handled. Skipping...\n", ptr.Offset));
+ continue;
+ }
+
+ m_handledStreams.insert(it, ptr.Offset);
+
if (ptr.Type == VSD_FONTFACES)
FontFaces[i] = ptr;
else if (ptr.Type == VSD_NAME_LIST2)
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index 5864b49..8df2cac 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <iostream>
+#include <set>
#include <vector>
#include <stack>
#include <map>
@@ -164,6 +165,9 @@ protected:
std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
VSDName m_currentPageName;
+ // Sanity check, to avoid problems with broken files.
+ std::set<unsigned> m_handledStreams;
+
private:
VSDParser();
VSDParser(const VSDParser &);
commit f5cc89fd3303fa60764e13addb3bee84adf7bbb5
Author: David Tardon <dtardon at redhat.com>
Date: Thu Nov 27 21:16:10 2014 +0100
move the check a bit up, in preparation for next commit
Change-Id: I9d7f98fecf96f162e2def0cd1af6931886fcb740
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index a30ba2a..9fe8080 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -201,13 +201,16 @@ void libvisio::VSDParser::handleStreams(librevenge::RVNGInputStream *input, unsi
{
Pointer ptr;
readPointer(input, ptr);
+ if (ptr.Type == 0)
+ continue;
+
if (ptr.Type == VSD_FONTFACES)
FontFaces[i] = ptr;
else if (ptr.Type == VSD_NAME_LIST2)
NameList[i] = ptr;
else if (ptr.Type == VSD_NAMEIDX || ptr.Type == VSD_NAMEIDX123)
NameIDX[i] = ptr;
- else if (ptr.Type != 0)
+ else if (ptr.Type)
PtrList[i] = ptr;
}
if (listSize <= 1)
More information about the Libreoffice-commits
mailing list