Fix for crash when loading some mango files
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 6 Mar 2012 13:57:28 +0000 (13:57 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 6 Mar 2012 13:57:28 +0000 (13:57 +0000)
Seems that issue is caused by several threads accessing to movie clip and one
of the threads (compositor node) was editing ImBuf which isn't nice anyway.

source/blender/nodes/composite/nodes/node_composite_movieclip.c

index 1f449f8c16adf5d23c8ea12d1bce5f9fc6fbf339..6ec64ef7c099b877254e55510f46b3e1a86f5249 100644 (file)
@@ -44,20 +44,23 @@ static bNodeSocketTemplate cmp_node_movieclip_out[]= {
 
 static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, MovieClipUser *user)
 {
-       ImBuf *ibuf;
+       ImBuf *orig_ibuf, *ibuf;
        CompBuf *stackbuf;
        int type;
 
        float *rect;
        int alloc= FALSE;
 
-       ibuf= BKE_movieclip_get_ibuf(clip, user);
+       orig_ibuf= BKE_movieclip_get_ibuf(clip, user);
 
-       if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
-               IMB_freeImBuf(ibuf);
+       if(orig_ibuf==NULL || (orig_ibuf->rect==NULL && orig_ibuf->rect_float==NULL)) {
+               IMB_freeImBuf(orig_ibuf);
                return NULL;
        }
 
+       ibuf= IMB_dupImBuf(orig_ibuf);
+       IMB_freeImBuf(orig_ibuf);
+
        if (ibuf->rect_float == NULL || ibuf->userflags&IB_RECT_INVALID) {
                IMB_float_from_rect(ibuf);
                ibuf->userflags&= ~IB_RECT_INVALID;