mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-01 02:03:47 +01:00
Savedata: Fix rare crash bug found in Google Play reports
This commit is contained in:
1 parent
dc0955655e
commit
f97a3d09bd
2 files changed
+8
-3
No files matched your search
@@ -136,6 +136,11 @@ inline size_t truncate_cpy(char(&out)[Count], std::string_view src) {
|
||||
return truncate_cpy(out, Count, src);
|
||||
}
|
||||
|
||||
template<size_t Count>
|
||||
inline std::string_view StringViewFromFixedSizeField(const char(&field)[Count]) {
|
||||
return std::string_view(field, strnlen(field, Count));
|
||||
}
|
||||
|
||||
inline std::string join(std::string_view a, std::string_view b) {
|
||||
std::string result;
|
||||
result.reserve(a.size() + b.size());
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace
|
||||
return result == dataSize;
|
||||
}
|
||||
|
||||
PSPFileInfo FileFromListing(const std::vector<PSPFileInfo> &listing, const std::string &filename) {
|
||||
static PSPFileInfo FileFromListing(const std::vector<PSPFileInfo> &listing, std::string_view filename) {
|
||||
for (const PSPFileInfo &sub : listing) {
|
||||
if (sub.name == filename)
|
||||
return sub;
|
||||
@@ -1426,12 +1426,12 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param) {
|
||||
s64 writeBytes = 0;
|
||||
for (int i = 0; i < param->sizeInfo->numNormalEntries; ++i) {
|
||||
const auto &entry = param->sizeInfo->normalEntries[i];
|
||||
overwriteBytes += FileFromListing(listing, entry.name).size;
|
||||
overwriteBytes += FileFromListing(listing, StringViewFromFixedSizeField(entry.name)).size;
|
||||
writeBytes += entry.size;
|
||||
}
|
||||
for (int i = 0; i < param->sizeInfo->numSecureEntries; ++i) {
|
||||
const auto &entry = param->sizeInfo->secureEntries[i];
|
||||
overwriteBytes += FileFromListing(listing, entry.name).size;
|
||||
overwriteBytes += FileFromListing(listing, StringViewFromFixedSizeField(entry.name)).size;
|
||||
writeBytes += entry.size + 0x10;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user