mirror of https://github.com/OpenRCT2/OpenRCT2.git
Close #16002: Segfault opening ride statistics for huge ride
This commit is contained in:
parent
510e86a4a4
commit
c2b33e3541
|
@ -10,17 +10,17 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
#include "../core/Guard.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
extern thread_local uint8_t gCommonFormatArgs[80];
|
extern thread_local uint8_t gCommonFormatArgs[80];
|
||||||
|
|
||||||
enum class ride_id_t : uint16_t;
|
enum class ride_id_t : uint16_t;
|
||||||
|
|
||||||
class Formatter
|
class Formatter
|
||||||
{
|
{
|
||||||
std::array<uint8_t, 80> Buffer{};
|
std::array<uint8_t, 256> Buffer{};
|
||||||
uint8_t* StartBuf{};
|
uint8_t* StartBuf{};
|
||||||
uint8_t* CurrentBuf{};
|
uint8_t* CurrentBuf{};
|
||||||
|
|
||||||
|
@ -59,7 +59,12 @@ public:
|
||||||
|
|
||||||
void Increment(size_t count)
|
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()
|
void Rewind()
|
||||||
|
|
Loading…
Reference in New Issue