Index: libmpc/branches/r2d/libmpcdec/Makefile.am
===================================================================
--- libmpc/branches/r2d/libmpcdec/Makefile.am	(revision 137)
+++ libmpc/branches/r2d/libmpcdec/Makefile.am	(revision 138)
@@ -10,2 +10,3 @@
 AM_CFLAGS = -DMPC_LITTLE_ENDIAN
 
+libmpcdec_la_LIBADD = $(top_builddir)/common/libcommon.a
Index: libmpc/branches/r2d/libmpcdec/mpc_demux.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 137)
+++ libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 138)
@@ -43,5 +43,7 @@
 
 // streaminfo.c
-mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in);
+mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si,
+									  const mpc_bits_reader * r_in,
+									  mpc_size_t block_size);
 mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in);
 void  streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in);
@@ -134,7 +136,9 @@
 		while( memcmp(b.key, "AD", 2) != 0 ){ // scan all blocks until audio
 			mpc_demux_fill(d, 11 + b.size, 0);
-			if (memcmp(b.key, "SI", 2) == 0)
-				streaminfo_read_header_sv8(&d->si, &d->bits_reader);
-			else if (memcmp(b.key, "EI", 2) == 0)
+			if (memcmp(b.key, "SI", 2) == 0){
+				int ret = streaminfo_read_header_sv8(&d->si, &d->bits_reader, b.size);
+				if (ret != MPC_STATUS_OK)
+					return ret;
+			} else if (memcmp(b.key, "EI", 2) == 0)
 				streaminfo_encoder_info(&d->si, &d->bits_reader);
 			else if (memcmp(b.key, "RG", 2) == 0)
@@ -161,7 +165,11 @@
 		p_tmp->block_bits = 0;
 		// lire entÃªte
-		mpc_demux_header(p_tmp);
-		// initialisation decodeur
-		p_tmp->d = mpc_decoder_init(&p_tmp->si);
+		if (mpc_demux_header(p_tmp) == MPC_STATUS_OK) {
+			// initialisation decodeur
+			p_tmp->d = mpc_decoder_init(&p_tmp->si);
+		} else {
+			free(p_tmp);
+			p_tmp = 0;
+		}
 	}
 
Index: libmpc/branches/r2d/libmpcdec/streaminfo.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/streaminfo.c	(revision 137)
+++ libmpc/branches/r2d/libmpcdec/streaminfo.c	(revision 138)
@@ -39,4 +39,6 @@
 #include <stdio.h>
 #include "internal.h"
+
+unsigned long crc32(unsigned char *buf, int len);
 
 mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits);
@@ -139,11 +141,15 @@
 /// Reads streaminfo from SV8 header.
 mpc_status
-streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in)
-{
-	mpc_uint32_t CRC;
+streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in,
+						   mpc_size_t block_size)
+{
+	mpc_uint32_t CRC, CRC_tmp;
 	mpc_bits_reader r = *r_in;
 
-	// FIXME : add CRC check
 	CRC = mpc_bits_read(&r, 32);
+	CRC_tmp = crc32(r.buff + 1 - (r.count >> 3), block_size - 4);
+	if (CRC != CRC_tmp)
+		return MPC_STATUS_FILE;
+
 	si->stream_version = mpc_bits_read(&r, 8);
 	mpc_bits_get_size(&r, &si->samples);
