diff --git a/ext/jpeg/gstmxpegdec.c b/ext/jpeg/gstmxpegdec.c
index 18f148b..5529750 100644
--- a/ext/jpeg/gstmxpegdec.c
+++ b/ext/jpeg/gstmxpegdec.c
@@ -604,7 +604,7 @@ gst_mxpeg_dec_decode_with_bitmap (GstMxpegDec * dec, guchar * base[3],
   int i, j;
   GstBitReader bitmapreader = GST_BIT_READER_INIT (dec->bitmap,
       dec->bitmap_len);
-  guchar *ref[3];
+  guchar *ref[3] = {0,};
 
   GST_DEBUG_OBJECT (dec, "MXM frame, taking slow route involving memcpy");
 
@@ -1123,6 +1123,7 @@ skip_decoding:
 done:
 
 exit:
+  gst_buffer_unref (buf);
 
   return ret;
 
