diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-05-26 14:52:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-05-26 14:52:39 +0400 |
commit | 37fab4a3e1b08c0fda42e73763f63c3443eb45fc (patch) | |
tree | 1a9f2c264a3ca2ceee580c2cbfdf59dbc8ba6348 /source/blender/windowmanager/intern/wm_files.c | |
parent | 440917cb0b2fe7f736d5911eb40318a0bfc8f0d4 (diff) |
bugfix [#22426] New Thumbnail code crashes when saving
patch from Ken Nign (ken9). (modified slightly)
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 91ebb5d6fb4..a6e59cde402 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -502,9 +502,7 @@ static void writeThumb(const char *path, Scene *scene, int **thumb_pt) if(G.background || scene->camera==NULL) return; - - thumb = MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb"); - + /* gets scaled to BLEN_THUMB_SIZE */ ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, OB_SOLID); @@ -514,16 +512,24 @@ static void writeThumb(const char *path, Scene *scene, int **thumb_pt) IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE); /* first write into thumb buffer */ + thumb= MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb"); + thumb[0] = BLEN_THUMB_SIZE; thumb[1] = BLEN_THUMB_SIZE; + memcpy(thumb + 2, ibuf->rect, BLEN_THUMB_SIZE * BLEN_THUMB_SIZE * sizeof(int)); /* the image is scaled here */ ibuf= IMB_thumb_create(path, THB_NORMAL, THB_SOURCE_BLEND, ibuf); - } - if (ibuf) { - IMB_freeImBuf(ibuf); + if (ibuf) + IMB_freeImBuf(ibuf); + + ibuf= NULL; + } + else { + /* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */ + thumb= NULL; } /* must be freed by caller */ |