Fixed two inconsistencies on failed allocation.
authorPhilipp Wiesemann
Sun, 08 Feb 2015 22:50:16 +0100
changeset 93361a1ec75b608c
parent 9335 3eb0896ecb91
child 9337 7e5940a2cda6
Fixed two inconsistencies on failed allocation.
src/render/opengl/SDL_render_gl.c
src/video/SDL_bmp.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Sun Feb 08 15:44:15 2015 -0500
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Sun Feb 08 22:50:16 2015 +0100
     1.3 @@ -342,9 +342,10 @@
     1.4  
     1.5      if (type == GL_DEBUG_TYPE_ERROR_ARB) {
     1.6          /* Record this error */
     1.7 -        char **error_messages = SDL_realloc(data->error_messages, data->errors * sizeof(*data->error_messages));
     1.8 -        ++data->errors;
     1.9 +        int errors = data->errors + 1;
    1.10 +        char **error_messages = SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages));
    1.11          if (error_messages) {
    1.12 +            data->errors = errors;
    1.13              data->error_messages = error_messages;
    1.14              data->error_messages[data->errors-1] = SDL_strdup(message);
    1.15          }
     2.1 --- a/src/video/SDL_bmp.c	Sun Feb 08 15:44:15 2015 -0500
     2.2 +++ b/src/video/SDL_bmp.c	Sun Feb 08 22:50:16 2015 +0100
     2.3 @@ -307,16 +307,17 @@
     2.4          }
     2.5          if ((int) biClrUsed > palette->ncolors) {
     2.6              SDL_Color *colors;
     2.7 -            palette->ncolors = biClrUsed;
     2.8 +            int ncolors = biClrUsed;
     2.9              colors =
    2.10                  (SDL_Color *) SDL_realloc(palette->colors,
    2.11 -                                          palette->ncolors *
    2.12 +                                          ncolors *
    2.13                                            sizeof(*palette->colors));
    2.14              if (!colors) {
    2.15                  SDL_OutOfMemory();
    2.16                  was_error = SDL_TRUE;
    2.17                  goto done;
    2.18              }
    2.19 +            palette->ncolors = ncolors;
    2.20              palette->colors = colors;
    2.21          } else if ((int) biClrUsed < palette->ncolors) {
    2.22              palette->ncolors = biClrUsed;