Skip to content

Commit

Permalink
Fixed two inconsistencies on failed allocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
philippwiesemann committed Feb 8, 2015
1 parent 78f3a80 commit e3f9bf3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/render/opengl/SDL_render_gl.c
Expand Up @@ -342,9 +342,10 @@ GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GL

if (type == GL_DEBUG_TYPE_ERROR_ARB) {
/* Record this error */
char **error_messages = SDL_realloc(data->error_messages, data->errors * sizeof(*data->error_messages));
++data->errors;
int errors = data->errors + 1;
char **error_messages = SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages));
if (error_messages) {
data->errors = errors;
data->error_messages = error_messages;
data->error_messages[data->errors-1] = SDL_strdup(message);
}
Expand Down
5 changes: 3 additions & 2 deletions src/video/SDL_bmp.c
Expand Up @@ -307,16 +307,17 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
}
if ((int) biClrUsed > palette->ncolors) {
SDL_Color *colors;
palette->ncolors = biClrUsed;
int ncolors = biClrUsed;
colors =
(SDL_Color *) SDL_realloc(palette->colors,
palette->ncolors *
ncolors *
sizeof(*palette->colors));
if (!colors) {
SDL_OutOfMemory();
was_error = SDL_TRUE;
goto done;
}
palette->ncolors = ncolors;
palette->colors = colors;
} else if ((int) biClrUsed < palette->ncolors) {
palette->ncolors = biClrUsed;
Expand Down

0 comments on commit e3f9bf3

Please sign in to comment.