diff options
| author | Kris De Gussem <kris.degussem@gmail.com> | 2013-04-03 20:47:48 +0000 |
|---|---|---|
| committer | Kris <Kris.De.Gussem@hotmail.com> | 2013-04-03 20:47:48 +0000 |
| commit | 3c213cec8c2aab1a53d0d5cb9d87659b584ac876 (patch) | |
| tree | c999ceaf1d985a8a3eee1f6dce37ebc7930ca9e0 /src/sp-image.cpp | |
| parent | Translations. Latvian translation update by Jānis Eisaks. (diff) | |
| download | inkscape-3c213cec8c2aab1a53d0d5cb9d87659b584ac876.tar.gz inkscape-3c213cec8c2aab1a53d0d5cb9d87659b584ac876.zip | |
Checking file presence before calling lstat (should fix Bug #785701 Inkscape freezes at opening)
(bzr r12263)
Diffstat (limited to 'src/sp-image.cpp')
| -rw-r--r-- | src/sp-image.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/sp-image.cpp b/src/sp-image.cpp index ce8879f70..dacea3417 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -417,8 +417,12 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& pixPath = NULL; } + //test correctness of filename + if (!g_file_test (filename, G_FILE_TEST_EXISTS)){ + return NULL; + } struct stat stdir; - g_stat(filename, &stdir); + int val = g_stat(filename, &stdir); if (stdir.st_mode & S_IFDIR){ //filename is not correct: it is a directory name and hence further code can not return valid results return NULL; @@ -429,11 +433,11 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& if ( fp ) { { - struct stat st; - memset(&st, 0, sizeof(st)); - int val = g_stat(filename, &st); + // struct stat st; + // memset(&st, 0, sizeof(st)); + // int val = g_stat(filename, &st); if ( !val ) { - modTime = st.st_mtime; + modTime = stdir.st_mtime;//st.st_mtime; pixPath = g_strdup(filename); } } @@ -1495,7 +1499,10 @@ void sp_image_refresh_if_outdated( SPImage* image ) struct stat st; memset(&st, 0, sizeof(st)); - int val = g_stat(image->pixPath, &st); + int val = 0; + if (g_file_test (image->pixPath, G_FILE_TEST_EXISTS)){ + val = g_stat(image->pixPath, &st); + } if ( !val ) { // stat call worked. Check time now if ( st.st_mtime != image->lastMod ) { |
