commit cc8b433532d9997081f1b9e7590ce8c90996e5be
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Sep 2018 20:56:50 -0700
changeset 59190a531f221f2
parent 590 8b4ee1d72a2a
child 592 31263a049d50
commit cc8b433532d9997081f1b9e7590ce8c90996e5be
Author: MichaƂ Janiszewski <janisozaur+signed@gmail.com>
Date: Fri Sep 28 20:52:21 2018 +0200

PNM: Improve checks when loading a file
IMG_pnm.c
     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