diff options
| author | Denis Declara <declara91@gmail.com> | 2012-05-05 13:32:42 +0000 |
|---|---|---|
| committer | Denis Declara <declara91@gmail.com> | 2012-05-05 13:32:42 +0000 |
| commit | aeb9c1bde66de096910757abb17dedb94ad74207 (patch) | |
| tree | c0adf97685b0fa8af1553b14d20601f280492762 /src/extension/system.cpp | |
| parent | Fixed some math, so that the objects now line up correctly (diff) | |
| parent | Adding checks to prevent null pointer dereferences (diff) | |
| download | inkscape-aeb9c1bde66de096910757abb17dedb94ad74207.tar.gz inkscape-aeb9c1bde66de096910757abb17dedb94ad74207.zip | |
Trunk merge
(bzr r11073.1.29)
Diffstat (limited to 'src/extension/system.cpp')
| -rw-r--r-- | src/extension/system.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/extension/system.cpp b/src/extension/system.cpp index ebad0c050..476499385 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -68,7 +68,26 @@ static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementatio */ SPDocument *open(Extension *key, gchar const *filename) { + // Convert to absolute pathname to tolerate chdir(). + bool relpath = (filename[0] != '/'); +#ifdef WIN32 + relpath &= (filename[0] != '\\') && !(isalpha(filename[0]) && (filename[1] == ':')); +#endif + + if (relpath) { + gchar * curdir = NULL; +#ifndef WIN32 + curdir = getcwd(NULL, 0); +#else + curdir = _getcwd(NULL, 0); +#endif + + filename = g_build_filename(curdir, filename, NULL); + free(curdir); + } + Input *imod = NULL; + if (key == NULL) { gpointer parray[2]; parray[0] = (gpointer)filename; @@ -108,6 +127,9 @@ SPDocument *open(Extension *key, gchar const *filename) } if (!imod->prefs(filename)) { + if (relpath){ + free((void *) filename); + } return NULL; } @@ -129,6 +151,9 @@ SPDocument *open(Extension *key, gchar const *filename) imod->set_gui(true); } + if (relpath){ + free((void *) filename); + } return doc; } |
