fix: bounds-check the toolchange flush-volume and HRC per-filament lookups (#15289)

* fix: bounds-check the toolchange flush-volume and HRC per-filament lookups

GCode::set_extruder's toolchange flush-volume lookup and
GCodeProcessor::update_slice_warnings's HRC check index per-filament and
per-extruder arrays (flush_volumes_matrix, the filament map, the nozzle list)
by filament/extruder id. When a config leaves one of those arrays shorter than
the filament count (partial or legacy multi-extruder projects, minimal
configs), the reads run off the end: silent on a normal STL, a hard abort under
_GLIBCXX_ASSERTIONS.

Route both reads through bounds checks: the flush lookup falls back to no flush,
matching the existing unknown-old-filament branch beside it, and the HRC check
skips an unmapped filament, mirroring the required_nozzle_HRC guard on the line
above. When the arrays are sized to the filament count the values are unchanged,
so correctly-specified configs are unaffected.

* ci: retrigger checks
This commit is contained in:
Kris Austin
2026-09-15 09:46:31 -03:00
committed by GitHub
parent bd1304443c
commit ac3997c0d1
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -9474,12 +9474,14 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
if (old_filament_id_in_new_extruder == -1)
wipe_volume = 0;
else {
wipe_volume = flush_matrix[old_filament_id_in_new_extruder * number_of_extruders + new_filament_id];
size_t flush_idx = size_t(old_filament_id_in_new_extruder) * number_of_extruders + new_filament_id;
wipe_volume = flush_idx < flush_matrix.size() ? flush_matrix[flush_idx] : 0.f;
wipe_volume *= m_config.flush_multiplier.get_at(new_extruder_id);
}
}
else {
wipe_volume = flush_matrix[old_filament_id * number_of_extruders + new_filament_id];
size_t flush_idx = size_t(old_filament_id) * number_of_extruders + new_filament_id;
wipe_volume = flush_idx < flush_matrix.size() ? flush_matrix[flush_idx] : 0.f;
wipe_volume *= m_config.flush_multiplier.get_at(new_extruder_id); // if is multi_extruder only use the fist extruder matrix
}
wipe_volume = std::max(0.f, wipe_volume-grab_purge_volume);