[Libreoffice-commits] .: 2 commits - src/lib

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 13 03:52:50 PST 2012


 src/lib/CDRDocument.cpp |   12 +++++++++++-
 src/lib/CMXDocument.cpp |    5 +++++
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 625677ba4ec9f0b0bb930fcefab5b7fc91b9bae8
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Dec 13 12:49:19 2012 +0100

    coverity: do not let CDRDocument::parse throw

diff --git a/src/lib/CDRDocument.cpp b/src/lib/CDRDocument.cpp
index 4a75389..2633954 100644
--- a/src/lib/CDRDocument.cpp
+++ b/src/lib/CDRDocument.cpp
@@ -129,7 +129,17 @@ bool libcdr::CDRDocument::parse(::WPXInputStream *input, libwpg::WPGPaintInterfa
 {
   input->seek(0, WPX_SEEK_SET);
   bool retVal = false;
-  unsigned version = getCDRVersion(input);
+  unsigned version = 0;
+  try
+  {
+    version = getCDRVersion(input);
+  }
+  catch (libcdr::EndOfStreamException const&)
+  {
+    // This can only happen if isSupported() has not been called before
+    return false;
+  }
+
   if (version)
   {
     input->seek(0, WPX_SEEK_SET);
commit c21b18b668b9efc0dc14257e1e43a85c1ccea807
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Dec 13 12:13:14 2012 +0100

    coverity: do not let CMXDocument::isSupported throw

diff --git a/src/lib/CMXDocument.cpp b/src/lib/CMXDocument.cpp
index 35d361d..9845552 100644
--- a/src/lib/CMXDocument.cpp
+++ b/src/lib/CMXDocument.cpp
@@ -45,6 +45,7 @@ Analyzes the content of an input stream to see if it can be parsed
 stream is a Corel Draw Document that libcdr is able to parse
 */
 bool libcdr::CMXDocument::isSupported(WPXInputStream *input)
+try
 {
   input->seek(0, WPX_SEEK_SET);
   unsigned riff = readU32(input);
@@ -62,6 +63,10 @@ bool libcdr::CMXDocument::isSupported(WPXInputStream *input)
     return false;
   return true;
 }
+catch (...)
+{
+  return false;
+}
 
 /**
 Parses the input stream content. It will make callbacks to the functions provided by a


More information about the Libreoffice-commits mailing list