all repos — mgba @ 86a2c45848582025e2a15e0fb67a6632ace2f482

mGBA Game Boy Advance Emulator

Fix memory corruption bug in GBAExtdataSerialize
nattthebear goyuken@gmail.com
Thu, 25 Feb 2016 21:25:30 -0500
commit

86a2c45848582025e2a15e0fb67a6632ace2f482

parent

9f6837da422c9f7b1a83e6ace63b23a2a8f1e393

1 files changed, 3 insertions(+), 3 deletions(-)

jump to
M src/gba/serialize.csrc/gba/serialize.c

@@ -514,14 +514,14 @@ }

bool GBAExtdataSerialize(struct GBAExtdata* extdata, struct VFile* vf) { ssize_t position = vf->seek(vf, 0, SEEK_CUR); - ssize_t size = 2; + ssize_t size = sizeof(struct GBAExtdataHeader); size_t i = 0; for (i = 1; i < EXTDATA_MAX; ++i) { if (extdata->data[i].data) { - size += sizeof(uint64_t) * 2; + size += sizeof(struct GBAExtdataHeader); } } - if (size == 2) { + if (size == sizeof(struct GBAExtdataHeader)) { return true; } struct GBAExtdataHeader* header = malloc(size);