mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-24 00:29:57 +00:00
Make sure the saved git ver is null terminated.
strncpy() is a tricky beast.
This commit is contained in:
parent
50e9e45d65
commit
2cca2568c7
@ -42,7 +42,6 @@
|
||||
#endif
|
||||
|
||||
#include "Common.h"
|
||||
#include "Core/Config.h"
|
||||
#include "FileUtil.h"
|
||||
#include "../ext/snappy/snappy-c.h"
|
||||
|
||||
@ -631,7 +630,7 @@ class CChunkFileReader
|
||||
public:
|
||||
// Load file template
|
||||
template<class T>
|
||||
static bool Load(const std::string& _rFilename, int _Revision, T& _class, std::string* _failureReason)
|
||||
static bool Load(const std::string& _rFilename, int _Revision, const char *_VersionString, T& _class, std::string* _failureReason)
|
||||
{
|
||||
INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
|
||||
_failureReason->clear();
|
||||
@ -676,7 +675,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(header.GitVersion, PPSSPP_GIT_VERSION) != 0)
|
||||
if (strcmp(header.GitVersion, _VersionString) != 0)
|
||||
{
|
||||
WARN_LOG(COMMON, "This savestate was generated by a different version of PPSSPP, %s. It may not load properly.",
|
||||
header.GitVersion);
|
||||
@ -723,7 +722,7 @@ public:
|
||||
|
||||
// Save file template
|
||||
template<class T>
|
||||
static bool Save(const std::string& _rFilename, int _Revision, T& _class)
|
||||
static bool Save(const std::string& _rFilename, int _Revision, const char *_VersionString, T& _class)
|
||||
{
|
||||
INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());
|
||||
|
||||
@ -753,7 +752,8 @@ public:
|
||||
header.Revision = _Revision;
|
||||
header.ExpectedSize = (int)sz;
|
||||
header.UncompressedSize = (int)sz;
|
||||
strncpy(header.GitVersion, PPSSPP_GIT_VERSION, 32);
|
||||
strncpy(header.GitVersion, _VersionString, 32);
|
||||
header.GitVersion[31] = '\0';
|
||||
|
||||
// Write to file
|
||||
if (compress) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "Common/FileUtil.h"
|
||||
|
||||
#include "Core/SaveState.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
@ -230,7 +231,7 @@ namespace SaveState
|
||||
if (MIPSComp::jit)
|
||||
MIPSComp::jit->ClearCache();
|
||||
INFO_LOG(COMMON, "Loading state from %s", op.filename.c_str());
|
||||
result = CChunkFileReader::Load(op.filename, REVISION, state, &reason);
|
||||
result = CChunkFileReader::Load(op.filename, REVISION, PPSSPP_GIT_VERSION, state, &reason);
|
||||
if (result) {
|
||||
osm.Show(s->T("Loaded State"), 2.0);
|
||||
} else {
|
||||
@ -242,7 +243,7 @@ namespace SaveState
|
||||
if (MIPSComp::jit)
|
||||
MIPSComp::jit->ClearCache();
|
||||
INFO_LOG(COMMON, "Saving state to %s", op.filename.c_str());
|
||||
result = CChunkFileReader::Save(op.filename, REVISION, state);
|
||||
result = CChunkFileReader::Save(op.filename, REVISION, PPSSPP_GIT_VERSION, state);
|
||||
if (result) {
|
||||
osm.Show(s->T("Saved State"), 2.0);
|
||||
} else {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "i18n/i18n.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/ui_atlas.h"
|
||||
|
Loading…
Reference in New Issue
Block a user