summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xml/repr-io.cpp17
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,