Close #16002: Segfault opening ride statistics for huge ride

This commit is contained in:
frutiemax 2022-01-01 08:10:42 -05:00 committed by GitHub
parent 510e86a4a4
commit c2b33e3541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -10,17 +10,17 @@
#pragma once
#include "../common.h"
#include "../core/Guard.hpp"
#include <array>
#include <cstring>
extern thread_local uint8_t gCommonFormatArgs[80];
enum class ride_id_t : uint16_t;
class Formatter
{
std::array<uint8_t, 80> Buffer{};
std::array<uint8_t, 256> Buffer{};
uint8_t* StartBuf{};
uint8_t* CurrentBuf{};
@ -59,7 +59,12 @@ public:
void Increment(size_t count)
{
CurrentBuf += count;
auto finalCount = NumBytes() + count;
Guard::Assert(finalCount < Buffer.size(), "Increment is greater than buffer size!");
if (finalCount < Buffer.size())
{
CurrentBuf += count;
}
}
void Rewind()