[XAM] Error check count in XUserStatsEnumerator

Fix Homefront from crashing
This commit is contained in:
Adrian 2024-08-08 13:11:03 +01:00 committed by Radosław Gliński
parent eeb96f91a5
commit adce6c0919
2 changed files with 14 additions and 0 deletions

View File

@ -120,6 +120,13 @@ uint32_t XAchievementEnumerator::WriteItems(uint32_t buffer_ptr,
uint32_t XUserStatsEnumerator::WriteItems(uint32_t buffer_ptr,
uint8_t* buffer_data,
uint32_t* written_count) {
size_t count = std::min(items_.size() - current_item_, items_per_enumerate());
if (!count) {
return X_ERROR_NO_MORE_FILES;
}
size_t size = count * item_size();
return X_ERROR_SUCCESS;
}

View File

@ -176,6 +176,12 @@ class XAchievementEnumerator : public XEnumerator {
class XUserStatsEnumerator : public XEnumerator {
public:
struct XUSER_STATS_SPEC {
xe::be<uint32_t> ViewId;
xe::be<uint32_t> NumColumnIds;
xe::be<uint16_t> rgwColumnIds[0x40];
};
XUserStatsEnumerator(KernelState* kernel_state, size_t items_per_enumerate)
: XEnumerator(kernel_state, items_per_enumerate, 0) {}
@ -183,6 +189,7 @@ class XUserStatsEnumerator : public XEnumerator {
uint32_t* written_count) override;
private:
std::vector<XUSER_STATS_SPEC> items_;
size_t current_item_ = 0;
};