IMG_xcf.c (read_string): kill C99'ism
authorOzkan Sezer <sezeroz@gmail.com>
Tue, 16 Oct 2018 20:20:40 +0300
changeset 6083ba4eff18ffd
parent 603 30fdc66faf6d
child 610 e21b8012c9b4
IMG_xcf.c (read_string): kill C99'ism
IMG_xcf.c
     1.1 --- a/IMG_xcf.c	Sun Oct 14 17:01:02 2018 +0300
     1.2 +++ b/IMG_xcf.c	Tue Oct 16 20:20:40 2018 +0300
     1.3 @@ -221,18 +221,20 @@
     1.4  }
     1.5  
     1.6  static char * read_string (SDL_RWops * src) {
     1.7 +  Sint64 remaining;
     1.8    Uint32 tmp;
     1.9    char * data;
    1.10  
    1.11    tmp = SDL_ReadBE32(src);
    1.12 -  Sint64 remaining = SDL_RWsize(src) - SDL_RWtell(src);
    1.13 -  if (tmp > 0 && tmp <= remaining) {
    1.14 +  remaining = SDL_RWsize(src) - SDL_RWtell(src);
    1.15 +  if (tmp > 0 && (Sint32)tmp <= remaining) {
    1.16      data = (char *) SDL_malloc (sizeof (char) * tmp);
    1.17      if (data) {
    1.18        SDL_RWread(src, data, tmp, 1);
    1.19        data[tmp - 1] = '\0';
    1.20      }
    1.21 -  } else {
    1.22 +  }
    1.23 +  else {
    1.24      data = NULL;
    1.25    }
    1.26    return data;