SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 2afeb7dee388c0605efad12c96b5c019e7ed6e8a parent ea67a7e3f0b6af75fc3ed29c0cad3adb0f99478d Author: Lior Halphon <LIJI32@gmail.com> Date: Mon, 17 May 2021 17:11:41 +0300 Place a cap on the GBS file size Diffstat:
| M | Core/gb.c | 6 | +++--- |
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Core/gb.c b/Core/gb.c @@ -462,13 +462,13 @@ int GB_load_gbs(GB_gameboy_t *gb, const char *path, GB_gbs_info_t *info) return errno; } fseek(f, 0, SEEK_END); - size_t file_size = ftell(f); + size_t file_size = MIN(ftell(f), sizeof(GB_gbs_header_t) + 0x4000 * 0x100); // Cap with the maximum MBC3 ROM size + GBS header fseek(f, 0, SEEK_SET); uint8_t *file_data = malloc(file_size); - fread(file_data,1,file_size,f); + fread(file_data, 1, file_size, f); fclose(f); - int r = GB_load_gbs_from_buffer(gb,file_data,file_size,info); + int r = GB_load_gbs_from_buffer(gb, file_data, file_size, info); free(file_data); return r; }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.