1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-09-02 19:39:12 +00:00

Fix: crash when opening a damaged base-graphics (#11275)

This commit is contained in:
Patric Stout
2023-09-09 16:06:00 +02:00
committed by GitHub
parent afc1ea8135
commit c3918838f6
2 changed files with 4 additions and 3 deletions

View File

@@ -146,9 +146,10 @@ void RandomAccessFile::ReadBlock(void *ptr, size_t size)
* Skip \a n bytes ahead in the file. * Skip \a n bytes ahead in the file.
* @param n Number of bytes to skip reading. * @param n Number of bytes to skip reading.
*/ */
void RandomAccessFile::SkipBytes(int n) void RandomAccessFile::SkipBytes(size_t n)
{ {
int remaining = this->buffer_end - this->buffer; assert(this->buffer_end >= this->buffer);
size_t remaining = this->buffer_end - this->buffer;
if (n <= remaining) { if (n <= remaining) {
this->buffer += n; this->buffer += n;
} else { } else {

View File

@@ -51,7 +51,7 @@ public:
uint32_t ReadDword(); uint32_t ReadDword();
void ReadBlock(void *ptr, size_t size); void ReadBlock(void *ptr, size_t size);
void SkipBytes(int n); void SkipBytes(size_t n);
}; };
#endif /* RANDOM_ACCESS_FILE_TYPE_H */ #endif /* RANDOM_ACCESS_FILE_TYPE_H */