Fixed two inconsistencies on failed allocation.

This commit is contained in:
Philipp Wiesemann 2015-02-08 22:50:16 +01:00
parent 78f3a80cf2
commit e3f9bf3378
2 changed files with 6 additions and 4 deletions

View File

@ -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);
}

View File

@ -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;