Changeset - r28288:9ec9776d7056
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 12 months ago 2023-12-14 15:41:31
j.g.rennison@gmail.com
Codechange: Use MakeParameters with GetNextParameter in FormatString (#11583)

Instead of StringParameters subspan, to avoid GSs being able to
cause subspan boundary assertion failures
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -1231,7 +1231,7 @@ static void FormatString(StringBuilder &
 
					}
 

	
 
					default: {
 
						StringParameters tmp_params(args, 1);
 
						auto tmp_params = MakeParameters(args.GetNextParameter<int64_t>());
 
						GetStringWithArgs(builder, cargo_str, tmp_params);
 
						break;
 
					}
 
@@ -1245,7 +1245,7 @@ static void FormatString(StringBuilder &
 
				if (IsValidCargoID(cargo) && cargo >= CargoSpec::GetArraySize()) break;
 

	
 
				StringID cargo_str = !IsValidCargoID(cargo) ? STR_QUANTITY_N_A : CargoSpec::Get(cargo)->quantifier;
 
				StringParameters tmp_args(args, 1);
 
				auto tmp_args = MakeParameters(args.GetNextParameter<int64_t>());
 
				GetStringWithArgs(builder, cargo_str, tmp_args);
 
				break;
 
			}
 
@@ -1405,7 +1405,7 @@ static void FormatString(StringBuilder &
 
			case SCC_DEPOT_NAME: { // {DEPOT}
 
				VehicleType vt = args.GetNextParameter<VehicleType>();
 
				if (vt == VEH_AIRCRAFT) {
 
					StringParameters tmp_params = StringParameters(args, 1);
 
					auto tmp_params = MakeParameters(args.GetNextParameter<StationID>());
 
					GetStringWithArgs(builder, STR_FORMAT_DEPOT_NAME_AIRCRAFT, tmp_params);
 
					break;
 
				}
0 comments (0 inline, 0 general)