Skip to content

Commit

Permalink
Revert "fix copy constructors"
Browse files Browse the repository at this point in the history
This reverts commit afb2d99.

This commit is wrong and ends up resulting in use after frees because of
C pointers. The proper solution is shared_ptr instead of C pointers but
that's a lot more involved than reverting this.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Feb 19, 2025
1 parent 6e680af commit ebff8b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ TiffEntryBase::TiffEntryBase(const TiffEntryBase& rhs) :
storage_(rhs.storage_) {
}

TiffDirectory::TiffDirectory(const TiffDirectory& rhs) : TiffComponent(rhs), hasNext_(rhs.hasNext_) {
}

TiffSubIfd::TiffSubIfd(const TiffSubIfd& rhs) : TiffEntryBase(rhs), newGroup_(rhs.newGroup_) {
}

TiffBinaryArray::TiffBinaryArray(const TiffBinaryArray& rhs) :
TiffEntryBase(rhs),
cfgSelFct_(rhs.cfgSelFct_),
arraySet_(rhs.arraySet_),
arrayCfg_(rhs.arrayCfg_),
arrayDef_(rhs.arrayDef_),
defSize_(rhs.defSize_),
setSize_(rhs.setSize_),
origData_(rhs.origData_),
origSize_(rhs.origSize_),
pRoot_(rhs.pRoot_) {
}

TiffComponent::UniquePtr TiffComponent::clone() const {
return UniquePtr(doClone());
}
Expand Down
6 changes: 3 additions & 3 deletions src/tiffcomposite_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ class TiffDirectory : public TiffComponent {
//! @name Protected Creators
//@{
//! Copy constructor (used to implement clone()).
TiffDirectory(const TiffDirectory&) = default;
TiffDirectory(const TiffDirectory& rhs);
//@}

//! @name Protected Manipulators
Expand Down Expand Up @@ -944,7 +944,7 @@ class TiffSubIfd : public TiffEntryBase {
//! @name Protected Creators
//@{
//! Copy constructor (used to implement clone()).
TiffSubIfd(const TiffSubIfd&) = default;
TiffSubIfd(const TiffSubIfd& rhs);
TiffSubIfd& operator=(const TiffSubIfd&) = delete;
//@}

Expand Down Expand Up @@ -1334,7 +1334,7 @@ class TiffBinaryArray : public TiffEntryBase {
//! @name Protected Creators
//@{
//! Copy constructor (used to implement clone()).
TiffBinaryArray(const TiffBinaryArray&) = default;
TiffBinaryArray(const TiffBinaryArray& rhs);
//@}

//! @name Protected Manipulators
Expand Down

0 comments on commit ebff8b4

Please sign in to comment.