Skip to content

Commit 2e381a7

Browse files
nightmarecislouken
authored andcommitted
Fix possible integer overflow of size + 1
1 parent 129ebc7 commit 2e381a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/io/SDL_iostream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio)
11531153
size = FILE_CHUNK_SIZE;
11541154
loading_chunks = true;
11551155
}
1156-
if (size >= SDL_SIZE_MAX) {
1156+
if (size >= SDL_SIZE_MAX - 1) {
11571157
goto done;
11581158
}
11591159
data = (char *)SDL_malloc((size_t)(size + 1));
@@ -1166,7 +1166,7 @@ void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio)
11661166
if (loading_chunks) {
11671167
if ((size_total + FILE_CHUNK_SIZE) > size) {
11681168
size = (size_total + FILE_CHUNK_SIZE);
1169-
if (size >= SDL_SIZE_MAX) {
1169+
if (size >= SDL_SIZE_MAX - 1) {
11701170
newdata = NULL;
11711171
} else {
11721172
newdata = (char *)SDL_realloc(data, (size_t)(size + 1));

0 commit comments

Comments
 (0)