diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index 6a8f46202fb44d559722f2eeaa94c59456d93bc6..a5458cac8ecfebdcb7a471485229913ab6f8e7dd 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -375,6 +375,8 @@ static int cinepak_decode (CinepakContext *s)
             s->frame.key_frame = 1;
 
         strip_size = AV_RB24 (&s->data[1]) - 12;
+        if(strip_size < 0)
+            return -1;
         s->data   += 12;
         strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;