pnmdec: make pnm_get more robust
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Aug 2012 18:57:40 +0000 (20:57 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Aug 2012 19:06:40 +0000 (21:06 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/pnm.c

index bfb4a25..a20051e 100644 (file)
@@ -34,12 +34,12 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
     int c;
 
     /* skip spaces and comments */
-    for (;;) {
+    while (sc->bytestream < sc->bytestream_end) {
         c = *sc->bytestream++;
         if (c == '#')  {
-            do {
+            while (c != '\n' && sc->bytestream < sc->bytestream_end) {
                 c = *sc->bytestream++;
-            } while (c != '\n' && sc->bytestream < sc->bytestream_end);
+            }
         } else if (!pnm_space(c)) {
             break;
         }