diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c
index e9cd6474b0c1477f889dc5961cec04f985a79c62..f08ed1d20d2953bcda2c0ba72a1a9a04338e263a 100644
--- a/libavformat/srtdec.c
+++ b/libavformat/srtdec.c
@@ -45,7 +45,7 @@ static int srt_probe(AVProbeData *p)
      * Also, that number can be followed by random garbage, so we can not
      * unfortunately check that we only have a number. */
     if (ff_subtitles_read_line(&tr, buf, sizeof(buf)) < 0 ||
-        strtol(buf, &pbuf, 10) < 0)
+        strtol(buf, &pbuf, 10) < 0 || pbuf == buf)
         return 0;
 
     /* Check if the next line matches a SRT timestamp */