diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 34ae368881e7ab1430a6a22fb5f3e2a8d4935736..413cc8963730f577f756fd68af6d5fee63e621d3 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -799,13 +799,13 @@ static int svq3_decode_frame (AVCodecContext *avctx,
         break;
       extradata++;
     }
-    size = BE_32(&extradata[4]);
 
     /* if a match was found, parse the extra data */
     if (!memcmp (extradata, "SEQH", 4)) {
 
       GetBitContext gb;
 
+      size = BE_32(&extradata[4]);
       init_get_bits (&gb, extradata + 8, size);
 
       /* 'frame size code' and optional 'width, height' */