$OpenBSD: patch-src_libraw_cxx_cpp,v 1.4 2013/06/18 18:39:58 sthen Exp $
--- src/libraw_cxx.cpp.orig	Tue Jun 18 19:23:59 2013
+++ src/libraw_cxx.cpp	Tue Jun 18 19:35:38 2013
@@ -798,8 +798,8 @@ int LibRaw::unpack(void)
                 S.iheight= S.height;
                 IO.shrink = 0;
                 // allocate image as temporary buffer, size 
-                imgdata.rawdata.raw_alloc = calloc(S.iwidth*S.iheight,sizeof(*imgdata.image));
-                imgdata.image = (ushort (*)[4]) imgdata.rawdata.raw_alloc;
+                imgdata.rawdata.raw_alloc = 0;
+                imgdata.image = (ushort (*)[4]) calloc(S.iwidth*S.iheight,sizeof(*imgdata.image));
             }
 
 
@@ -809,8 +809,8 @@ int LibRaw::unpack(void)
         // recover saved
         if( decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
             {
-                imgdata.image = 0; 
-                imgdata.rawdata.color_image = (ushort (*)[4]) imgdata.rawdata.raw_alloc;
+                imgdata.rawdata.raw_alloc = imgdata.rawdata.color_image = imgdata.image;
+                imgdata.image = 0;
             }
 
         // calculate channel maximum
