Fixed undefined behavior (dereferencing std::unique_ptr pointing to nullptr) in the G-Code processing pipeline.

This commit is contained in:
Lukáš Hejl 2022-10-18 01:23:47 +02:00 committed by Lukas Matena
parent a0a0b0d253
commit 411535ecdf

View File

@ -1502,27 +1502,27 @@ void GCode::process_layers(
} }
}); });
const auto spiral_vase = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order, const auto spiral_vase = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order,
[&spiral_vase = *this->m_spiral_vase](LayerResult in) -> LayerResult { [spiral_vase = this->m_spiral_vase.get()](LayerResult in) -> LayerResult {
if (in.nop_layer_result) if (in.nop_layer_result)
return in; return in;
spiral_vase.enable(in.spiral_vase_enable); spiral_vase->enable(in.spiral_vase_enable);
return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush}; return { spiral_vase->process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush};
}); });
const auto pressure_equalizer = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order, const auto pressure_equalizer = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order,
[&pressure_equalizer = *this->m_pressure_equalizer](LayerResult in) -> LayerResult { [pressure_equalizer = this->m_pressure_equalizer.get()](LayerResult in) -> LayerResult {
return pressure_equalizer.process_layer(std::move(in)); return pressure_equalizer->process_layer(std::move(in));
}); });
const auto cooling = tbb::make_filter<LayerResult, std::string>(slic3r_tbb_filtermode::serial_in_order, const auto cooling = tbb::make_filter<LayerResult, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&cooling_buffer = *this->m_cooling_buffer](LayerResult in) -> std::string { [cooling_buffer = this->m_cooling_buffer.get()](LayerResult in) -> std::string {
if (in.nop_layer_result) if (in.nop_layer_result)
return in.gcode; return in.gcode;
return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush); return cooling_buffer->process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush);
}); });
const auto find_replace = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order, const auto find_replace = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&self = *this->m_find_replace](std::string s) -> std::string { [find_replace = this->m_find_replace.get()](std::string s) -> std::string {
return self.process_layer(std::move(s)); return find_replace->process_layer(std::move(s));
}); });
const auto output = tbb::make_filter<std::string, void>(slic3r_tbb_filtermode::serial_in_order, const auto output = tbb::make_filter<std::string, void>(slic3r_tbb_filtermode::serial_in_order,
[&output_stream](std::string s) { output_stream.write(s); } [&output_stream](std::string s) { output_stream.write(s); }
@ -1584,25 +1584,25 @@ void GCode::process_layers(
} }
}); });
const auto spiral_vase = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order, const auto spiral_vase = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order,
[&spiral_vase = *this->m_spiral_vase](LayerResult in)->LayerResult { [spiral_vase = this->m_spiral_vase.get()](LayerResult in)->LayerResult {
if (in.nop_layer_result) if (in.nop_layer_result)
return in; return in;
spiral_vase.enable(in.spiral_vase_enable); spiral_vase->enable(in.spiral_vase_enable);
return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush }; return { spiral_vase->process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
}); });
const auto pressure_equalizer = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order, const auto pressure_equalizer = tbb::make_filter<LayerResult, LayerResult>(slic3r_tbb_filtermode::serial_in_order,
[&pressure_equalizer = *this->m_pressure_equalizer](LayerResult in) -> LayerResult { [pressure_equalizer = this->m_pressure_equalizer.get()](LayerResult in) -> LayerResult {
return pressure_equalizer.process_layer(std::move(in)); return pressure_equalizer->process_layer(std::move(in));
}); });
const auto cooling = tbb::make_filter<LayerResult, std::string>(slic3r_tbb_filtermode::serial_in_order, const auto cooling = tbb::make_filter<LayerResult, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&cooling_buffer = *this->m_cooling_buffer](LayerResult in)->std::string { [cooling_buffer = this->m_cooling_buffer.get()](LayerResult in)->std::string {
if (in.nop_layer_result) if (in.nop_layer_result)
return in.gcode; return in.gcode;
return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush); return cooling_buffer->process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush);
}); });
const auto find_replace = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order, const auto find_replace = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&self = *this->m_find_replace](std::string s) -> std::string { [find_replace = this->m_find_replace.get()](std::string s) -> std::string {
return self.process_layer(std::move(s)); return find_replace->process_layer(std::move(s));
}); });
const auto output = tbb::make_filter<std::string, void>(slic3r_tbb_filtermode::serial_in_order, const auto output = tbb::make_filter<std::string, void>(slic3r_tbb_filtermode::serial_in_order,
[&output_stream](std::string s) { output_stream.write(s); } [&output_stream](std::string s) { output_stream.write(s); }