diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-02 14:22:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-02 14:22:49 +0400 |
commit | 02fbaede8f33b4acc3421e6d641dfa9359a264da (patch) | |
tree | 090e675178c3797ecbd0d7cdfbaf20a268f3e9a4 /source/blender/imbuf | |
parent | 1357443e48881617462463bf8e9037e4fa487d79 (diff) |
workaround [#27203] Crashes with some high-res image thumbnail generation
skip generating thumbs for images over 100mb.
also pass string lengths as size_t rather then int for path_util.c functions.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_thumbs.h | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/thumbs.c | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h index 583a677ebd9..f5e63b73cb1 100644 --- a/source/blender/imbuf/IMB_thumbs.h +++ b/source/blender/imbuf/IMB_thumbs.h @@ -59,6 +59,9 @@ typedef enum ThumbSource { THB_SOURCE_BLEND } ThumbSource; +/* dont generate thumbs for images bigger then this (100mb) */ +#define THUMB_SIZE_MAX (100 * 1024*1024) + // IB_metadata /* create thumbnail for file and returns new imbuf for thumbnail */ diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 3e17665fa39..1d91f34f4fa 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -275,6 +275,15 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im return NULL; /* unknown size */ } + /* exception, skip images over 100mb */ + if(source == THB_SOURCE_IMAGE) { + const size_t size= BLI_filepathsize(path); + if(size != -1 && size > THUMB_SIZE_MAX) { + // printf("file too big: %d, skipping %s\n", (int)size, path); + return NULL; + } + } + uri_from_filename(path, uri); thumbname_from_uri(uri, thumb, sizeof(thumb)); if (get_thumb_dir(tdir, size)) { |