summaryrefslogtreecommitdiff
path: root/src/crashlog.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2019-04-25 22:55:16 +0100
committerPeterN <peter@fuzzle.org>2019-04-29 17:43:27 +0100
commit47d0d86a3c31c3b9ae71e5bed5007d0ba0a1337d (patch)
tree82a3442744cdd03f74550c4e1e24a562f38648e7 /src/crashlog.cpp
parent9e19a5f93e3d79ac30bec14b6e0ba673b7073863 (diff)
downloadopenttd-47d0d86a3c31c3b9ae71e5bed5007d0ba0a1337d.tar.xz
Fix #7255: Prevent crashlog corruption by only printing the 32 most recent news messages
Diffstat (limited to 'src/crashlog.cpp')
-rw-r--r--src/crashlog.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crashlog.cpp b/src/crashlog.cpp
index 531b5c64c..bcad5e35f 100644
--- a/src/crashlog.cpp
+++ b/src/crashlog.cpp
@@ -303,7 +303,7 @@ char *CrashLog::LogGamelog(char *buffer, const char *last) const
}
/**
- * Writes any recent news messages to the buffer.
+ * Writes up to 32 recent news messages to the buffer, with the most recent first.
* @param buffer The begin where to write at.
* @param last The last position in the buffer to write to.
* @return the position of the \c '\0' character after the buffer.
@@ -312,7 +312,8 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const
{
buffer += seprintf(buffer, last, "Recent news messages:\n");
- for (NewsItem *news = _oldest_news; news != nullptr; news = news->next) {
+ int i = 0;
+ for (NewsItem *news = _latest_news; i < 32 && news != nullptr; news = news->prev, i++) {
YearMonthDay ymd;
ConvertDateToYMD(news->date, &ymd);
buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",