Skip to content

Commit

Permalink
remove std::swap workaround
Browse files Browse the repository at this point in the history
std::swap was added here to avoid a use after move warning. But in
reality, the second usage of object is wrong and should be changed to
nullptr.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Feb 20, 2025
1 parent 739bd6d commit 8cec5b0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,7 @@ TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCo

auto atc = [&] {
if (tiffPath.size() == 1 && object) {
TiffComponent::UniquePtr tempObject;
std::swap(object, tempObject);
return tempObject;
return std::move(object);
}
return TiffCreator::create(tpi.extendedTag(), tpi.group());
}();
Expand All @@ -457,7 +455,7 @@ TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCo
return this->addNext(std::move(atc));
return this->addChild(std::move(atc));
}();
return tc->addPath(tag, tiffPath, pRoot, std::move(object));
return tc->addPath(tag, tiffPath, pRoot, nullptr);
} // TiffDirectory::doAddPath

TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
Expand Down

0 comments on commit 8cec5b0

Please sign in to comment.