Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1802 - NULL pointer dereference in SDL_AllocRW() if out of …
Browse files Browse the repository at this point in the history
…memory.

Philipp Wiesemann

There is a NULL pointer dereference in SDL_AllocRW() if the system is out of memory. The "type" field is always written. This may be fixed with an early return.

Or an else{} or not writing the field and using slower SDL_calloc().

This fault was recently introduced (http://hg.libsdl.org/SDL/rev/681820ca0e78).
  • Loading branch information
slouken committed Apr 17, 2013
1 parent e77deee commit da003fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/file/SDL_rwops.c
Expand Up @@ -628,8 +628,9 @@ SDL_AllocRW(void)
area = (SDL_RWops *) SDL_malloc(sizeof *area);
if (area == NULL) {
SDL_OutOfMemory();
} else {
area->type = SDL_RWOPS_UNKNOWN;
}
area->type = SDL_RWOPS_UNKNOWN;
return (area);
}

Expand Down

0 comments on commit da003fd

Please sign in to comment.