all repos — mgba @ 867559d5c1c4ff6a28178dda7eb74b8f2636535d

mGBA Game Boy Advance Emulator

Core: Fix stack bound error
Vicki Pfau vi@endrift.com
Sat, 08 Sep 2018 14:08:45 -0700
commit

867559d5c1c4ff6a28178dda7eb74b8f2636535d

parent

eb4ef6d8a72b35bd39ba4109206c52674930b421

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

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

@@ -305,20 +305,20 @@ mStateExtdataInit(&extdata);

size_t stateSize = core->stateSize(core); if (flags & SAVESTATE_METADATA) { - uint64_t creationUsec; + uint64_t* creationUsec = malloc(sizeof(*creationUsec)); #ifndef _MSC_VER struct timeval tv; if (!gettimeofday(&tv, 0)) { uint64_t usec = tv.tv_usec; usec += tv.tv_sec * 1000000LL; - STORE_64LE(usec, 0, &creationUsec); + STORE_64LE(usec, 0, creationUsec); } #else struct timespec ts; if (timespec_get(&ts, TIME_UTC)) { uint64_t usec = ts.tv_nsec / 1000; usec += ts.tv_sec * 1000000LL; - STORE_64LE(usec, 0, &creationUsec); + STORE_64LE(usec, 0, creationUsec); } #endif else {

@@ -326,9 +326,9 @@ creationUsec = 0;

} struct mStateExtdataItem item = { - .size = sizeof(creationUsec), - .data = &creationUsec, - .clean = NULL + .size = sizeof(*creationUsec), + .data = creationUsec, + .clean = free }; mStateExtdataPut(&extdata, EXTDATA_META_TIME, &item); }