IMG_pnm.c
changeset 591 90a531f221f2
parent 587 32a18ca05935
child 618 cbf3b5d96be6
     1.1 --- a/IMG_pnm.c	Wed Sep 26 22:53:30 2018 +0200
     1.2 +++ b/IMG_pnm.c	Fri Sep 28 20:56:50 2018 -0700
     1.3 @@ -86,7 +86,14 @@
     1.4      } while ( SDL_isspace(ch) );
     1.5  
     1.6      /* Add up the number */
     1.7 +    if (!SDL_isdigit(ch)) {
     1.8 +        return -1;
     1.9 +    }
    1.10      do {
    1.11 +        /* Protect from possible overflow */
    1.12 +        if (number >= INT32_MAX / 10) {
    1.13 +            return -1;
    1.14 +        }
    1.15          number *= 10;
    1.16          number += ch-'0';
    1.17