mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-20 13:06:05 +00:00
Make sure we set datasize on error in SDL_LoadFile_RW()
This commit is contained in:
parent
dff76bf295
commit
2d94b4f490
1 changed files with 5 additions and 5 deletions
|
|
@ -625,14 +625,14 @@ void SDL_DestroyRW(SDL_RWops *context)
|
|||
void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
|
||||
{
|
||||
const int FILE_CHUNK_SIZE = 1024;
|
||||
Sint64 size, size_total;
|
||||
Sint64 size, size_total = 0;
|
||||
size_t size_read;
|
||||
char *data = NULL, *newdata;
|
||||
SDL_bool loading_chunks = SDL_FALSE;
|
||||
|
||||
if (!src) {
|
||||
SDL_InvalidParamError("src");
|
||||
return NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
size = SDL_RWsize(src);
|
||||
|
|
@ -677,12 +677,12 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
|
|||
break;
|
||||
}
|
||||
|
||||
if (datasize) {
|
||||
*datasize = (size_t)size_total;
|
||||
}
|
||||
data[size_total] = '\0';
|
||||
|
||||
done:
|
||||
if (datasize) {
|
||||
*datasize = (size_t)size_total;
|
||||
}
|
||||
if (freesrc && src) {
|
||||
SDL_RWclose(src);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue