Fix savestates. Still don't understand quite how this broke though, it should work. Fixes #9365

This commit is contained in:
Henrik Rydgård 2017-02-28 00:03:32 +01:00
parent 5de190a45f
commit 0e83a4c418

View File

@ -29,8 +29,9 @@ PointerWrapSection PointerWrap::Section(const char *title, int minVer, int ver)
char marker[16] = {0};
int foundVersion = ver;
truncate_cpy(marker, title);
if (!ExpectVoid(marker, sizeof(marker))) {
strncpy(marker, title, sizeof(marker));
if (!ExpectVoid(marker, sizeof(marker)))
{
// Might be before we added name markers for safety.
if (foundVersion == 1 && ExpectVoid(&foundVersion, sizeof(foundVersion)))
DoMarker(title);
@ -283,11 +284,13 @@ CChunkFileReader::Error CChunkFileReader::SaveFile(const std::string &filename,
header.Revision = REVISION_CURRENT;
header.ExpectedSize = (u32)sz;
header.UncompressedSize = (u32)sz;
truncate_cpy(header.GitVersion, gitVersion);
strncpy(header.GitVersion, gitVersion, 32);
header.GitVersion[31] = '\0';
// Setup the fixed-length title.
char titleFixed[128];
truncate_cpy(titleFixed, title.c_str());
strncpy(titleFixed, title.c_str(), sizeof(titleFixed));
titleFixed[sizeof(titleFixed) - 1] = '\0';
// Write to file
if (compress) {