diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index aff656688c8fb36e42ce4243bcaab2c7954a0903..18d2700492b7bbeaf71e69cea348e5e772523b6b 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -140,6 +140,10 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
         s->nodes[i].sym = i;
         s->nodes[i].count = LE_32(src);
         s->nodes[i].n0 = -2;
+        if(s->nodes[i].count < 0) {
+            av_log(s->avctx, AV_LOG_ERROR, "Symbol count < 0\n");
+            return -1;
+        }
         src += 4;
         sum += s->nodes[i].count;
     }