From 460110303c656518a93470d15f0a931121e05e68 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 7 Dec 2024 20:42:45 +0000 Subject: [PATCH] Fix #13155: Set number of parameters when assigning from GRFConfig to GRFFile. --- src/newgrf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 0c1b8b1e03..94dda9a824 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -9007,7 +9007,8 @@ GRFFile::GRFFile(const GRFConfig *config) * 'Uninitialised' parameters are zeroed as that is their default value when dynamically creating them. */ this->param = {}; - auto last = std::begin(config->param) + std::min(std::size(config->param), GRFConfig::MAX_NUM_PARAMS); + this->param_end = std::min(static_cast(std::size(config->param)), GRFConfig::MAX_NUM_PARAMS); + auto last = std::begin(config->param) + this->param_end; std::copy(std::begin(config->param), last, std::begin(this->param)); }