IMG_pnm.c
changeset 591 90a531f221f2
parent 587 32a18ca05935
child 618 cbf3b5d96be6
equal deleted inserted replaced
590:8b4ee1d72a2a 591:90a531f221f2
    84             } while ( (ch != '\r') && (ch != '\n') );
    84             } while ( (ch != '\r') && (ch != '\n') );
    85         }
    85         }
    86     } while ( SDL_isspace(ch) );
    86     } while ( SDL_isspace(ch) );
    87 
    87 
    88     /* Add up the number */
    88     /* Add up the number */
       
    89     if (!SDL_isdigit(ch)) {
       
    90         return -1;
       
    91     }
    89     do {
    92     do {
       
    93         /* Protect from possible overflow */
       
    94         if (number >= INT32_MAX / 10) {
       
    95             return -1;
       
    96         }
    90         number *= 10;
    97         number *= 10;
    91         number += ch-'0';
    98         number += ch-'0';
    92 
    99 
    93         if ( !SDL_RWread(src, &ch, 1, 1) ) {
   100         if ( !SDL_RWread(src, &ch, 1, 1) ) {
    94             return -1;
   101             return -1;