Fixed bug 1802 - NULL pointer dereference in SDL_AllocRW() if out of 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).
This commit is contained in:
Sam Lantinga
2013-04-17 01:32:06 -07:00
parent ec2f595166
commit 4f8c0f33f9

View File

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