diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index 4149a6761f37d8765db44fd8627b21b33f7752d6..9069b7e3900a1a02be3266d56370ef5e9d7b1825 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -330,6 +330,10 @@ static int cinepak_decode (CinepakContext *s)
 
     /* if this is the first frame, check for deviant Sega FILM data */
     if (s->sega_film_skip_bytes == -1) {
+        if (!encoded_buf_size){
+            av_log_ask_for_sample(s->avctx, "encoded_buf_size is 0");
+            return -1;
+        }
         if (encoded_buf_size != s->size && (s->size % encoded_buf_size) != 0) {
             /* If the encoded frame size differs from the frame size as indicated
              * by the container file, this data likely comes from a Sega FILM/CPK file.