Skip to content

Commit

Permalink
fix: Sequencer use-after-move in sequencer data flow check (#1941)
Browse files Browse the repository at this point in the history
If Sequencer data flow checks are turned on, there's a use-after-move bug that this PR fixes.
  • Loading branch information
paulgessinger committed Mar 14, 2023
1 parent b30b9b8 commit 58bb693
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Sequencer {
/// Append a sequence element to the sequence
///
/// @throws std::invalid_argument if the element is NULL.
void addElement(std::shared_ptr<SequenceElement> element);
void addElement(const std::shared_ptr<SequenceElement> &element);

/// Add a writer to the set of writers.
///
Expand Down
4 changes: 2 additions & 2 deletions Examples/Framework/src/Framework/Sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ void Sequencer::addWriter(std::shared_ptr<IWriter> writer) {
addElement(std::move(writer));
}

void Sequencer::addElement(std::shared_ptr<SequenceElement> element) {
void Sequencer::addElement(const std::shared_ptr<SequenceElement>& element) {
if (not element) {
throw std::invalid_argument("Can not add empty/NULL element");
}

m_sequenceElements.push_back(std::move(element));
m_sequenceElements.push_back(element);

if (!m_cfg.runDataFlowChecks) {
return;
Expand Down

0 comments on commit 58bb693

Please sign in to comment.