=== OpenEXR ===
[blender.git] / source / blender / imbuf / intern / openexr / openexr_api.cpp
index 983ab101893ae179cf9f868a24d77c537d5970bf..3cbada812b9da8868c155f55b1f748bd24465544 100644 (file)
@@ -873,9 +873,9 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
        
        try
        {
-               Mem_IStream membuf(mem, size); 
+               Mem_IStream *membuf = new Mem_IStream(mem, size); 
                int is_multi;
-               file = new InputFile(membuf);
+               file = new InputFile(*membuf);
                
                Box2i dw = file->header().dataWindow();
                int width  = dw.max.x - dw.min.x + 1;
@@ -946,8 +946,8 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
                                }
                        }
                        
-                       delete file;
                }
+               delete file;
                
                return(ibuf);
                                
@@ -956,6 +956,7 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
        {
                std::cerr << exc.what() << std::endl;
                if (ibuf) IMB_freeImBuf(ibuf);
+               delete file;
                
                return (0);
        }