diff options
| author | Carl Hetherington <cth@carlh.net> | 2006-01-23 14:19:27 +0000 |
|---|---|---|
| committer | cth103 <cth103@users.sourceforge.net> | 2006-01-23 14:19:27 +0000 |
| commit | 88a8b1c9b15c12ff99ffc0f9c387ad1a1bdca813 (patch) | |
| tree | e9bbd7451de9f040b51c2408db0e3307558fc233 /src/xml/repr-io.cpp | |
| parent | Add .a files to svn:ignore property. (diff) | |
| download | inkscape-88a8b1c9b15c12ff99ffc0f9c387ad1a1bdca813.tar.gz inkscape-88a8b1c9b15c12ff99ffc0f9c387ad1a1bdca813.zip | |
Catch failures in fopen of XML files. Fixes #1374551.
(bzr r23)
Diffstat (limited to 'src/xml/repr-io.cpp')
| -rw-r--r-- | src/xml/repr-io.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 02aca4dc6..bb62393fc 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -16,7 +16,7 @@ # include <config.h> #endif - +#include <stdexcept> #include "xml/repr.h" #include "xml/attribute-record.h" @@ -80,9 +80,13 @@ private: Inkscape::IO::GzipInputStream* gzin; }; -void XmlSource::setFile( char const * filename ) { +void XmlSource::setFile(char const *filename) +{ this->filename = filename; fp = Inkscape::IO::fopen_utf8name(filename, "r"); + if (fp == NULL) { + throw std::runtime_error("Could not open file for reading"); + } first = true; } @@ -214,7 +218,14 @@ sp_repr_read_file (const gchar * filename, const gchar *default_ns) Inkscape::IO::dump_fopen_call( filename, "N" ); XmlSource src; - src.setFile(filename); + try + { + src.setFile(filename); + } + catch (...) + { + return NULL; + } xmlDocPtr doubleDoc = xmlReadIO( XmlSource::readCb, XmlSource::closeCb, |
