From 50052daf214517017841673909a105e6825e481e Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Wed, 19 Feb 2025 22:13:20 +0000 Subject: [PATCH 1/7] Use unique_ptr rather than raw pointer. --- src/tiffcomposite_int.cpp | 63 ++++++++++++++++----------------------- src/tiffcomposite_int.hpp | 14 ++++----- src/tiffvisitor_int.cpp | 4 +-- 3 files changed, 34 insertions(+), 47 deletions(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index f4bb5037bd..854450344a 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -89,28 +89,13 @@ TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arra // We'll figure out the correct cfg later } -TiffDirectory::~TiffDirectory() { - for (auto&& component : components_) { - delete component; - } - delete pNext_; -} +TiffDirectory::~TiffDirectory() {} -TiffSubIfd::~TiffSubIfd() { - for (auto&& ifd : ifds_) { - delete ifd; - } -} +TiffSubIfd::~TiffSubIfd() {} -TiffEntryBase::~TiffEntryBase() { - delete pValue_; -} +TiffEntryBase::~TiffEntryBase() {} -TiffBinaryArray::~TiffBinaryArray() { - for (auto&& element : elements_) { - delete element; - } -} +TiffBinaryArray::~TiffBinaryArray() {} TiffEntryBase::TiffEntryBase(const TiffEntryBase& rhs) : TiffComponent(rhs), @@ -228,8 +213,7 @@ void TiffEntryBase::setValue(Value::UniquePtr value) { return; tiffType_ = toTiffType(value->typeId()); count_ = value->count(); - delete pValue_; - pValue_ = value.release(); + std::swap(pValue_, value); } void TiffDataEntry::setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) { @@ -446,11 +430,11 @@ TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCo // condition takes care of them, see below. if (tiffPath.size() > 1 || (tpi.extendedTag() == 0x927c && tpi.group() == IfdId::exifId)) { if (tpi.extendedTag() == Tag::next) { - tc = pNext_; + tc = pNext_.get(); } else { for (auto&& component : components_) { if (component->tag() == tpi.tag() && component->group() == tpi.group()) { - tc = component; + tc = component.get(); break; } } @@ -576,14 +560,18 @@ TiffComponent* TiffComponent::doAddChild(UniquePtr /*tiffComponent*/) { } // TiffComponent::doAddChild TiffComponent* TiffDirectory::doAddChild(TiffComponent::UniquePtr tiffComponent) { - TiffComponent* tc = tiffComponent.release(); - components_.push_back(tc); + TiffComponent* tc = tiffComponent.get(); + components_.push_back(std::move(tiffComponent)); return tc; } // TiffDirectory::doAddChild TiffComponent* TiffSubIfd::doAddChild(TiffComponent::UniquePtr tiffComponent) { - auto d = dynamic_cast(tiffComponent.release()); - ifds_.push_back(d); + auto d = dynamic_cast(tiffComponent.get()); + if (!d) { + throw Error(ErrorCode::kerErrorMessage, "dynamic_cast to TiffDirectory failed"); + } + tiffComponent.release(); + ifds_.push_back(std::unique_ptr(d)); return d; } // TiffSubIfd::doAddChild @@ -600,8 +588,8 @@ TiffComponent* TiffIfdMakernote::doAddChild(TiffComponent::UniquePtr tiffCompone } TiffComponent* TiffBinaryArray::doAddChild(TiffComponent::UniquePtr tiffComponent) { - TiffComponent* tc = tiffComponent.release(); - elements_.push_back(tc); + TiffComponent* tc = tiffComponent.get(); + elements_.push_back(std::move(tiffComponent)); setDecoded(true); return tc; } // TiffBinaryArray::doAddChild @@ -615,12 +603,11 @@ TiffComponent* TiffComponent::doAddNext(UniquePtr /*tiffComponent*/) { } // TiffComponent::doAddNext TiffComponent* TiffDirectory::doAddNext(TiffComponent::UniquePtr tiffComponent) { - TiffComponent* tc = nullptr; if (hasNext_) { - tc = tiffComponent.release(); - pNext_ = tc; + std::swap(pNext_, tiffComponent); + return pNext_.get(); } - return tc; + return nullptr; } // TiffDirectory::doAddNext TiffComponent* TiffMnEntry::doAddNext(TiffComponent::UniquePtr tiffComponent) { @@ -876,7 +863,7 @@ size_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t idx += 2; // b) Directory entries - may contain pointers to the value or data for (auto&& component : components_) { - idx += writeDirEntry(ioWrapper, byteOrder, offset, component, valueIdx, dataIdx, imageIdx); + idx += writeDirEntry(ioWrapper, byteOrder, offset, component.get(), valueIdx, dataIdx, imageIdx); if (size_t sv = component->size(); sv > 4) { sv += sv & 1; // Align value to word boundary valueIdx += sv; @@ -1205,7 +1192,7 @@ size_t TiffComponent::writeImage(IoWrapper& ioWrapper, ByteOrder byteOrder) cons size_t TiffDirectory::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const { size_t len = 0; TiffComponent* pSubIfd = nullptr; - for (auto component : components_) { + for (auto& component : components_) { if (component->tag() == 0x014a) { // Hack: delay writing of sub-IFD image data to get the order correct #ifndef SUPPRESS_WARNINGS @@ -1213,7 +1200,7 @@ size_t TiffDirectory::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) co EXV_ERROR << "Multiple sub-IFD image data tags found\n"; } #endif - pSubIfd = component; + pSubIfd = component.get(); continue; } len += component->writeImage(ioWrapper, byteOrder); @@ -1502,13 +1489,13 @@ TiffType toTiffType(TypeId typeId) { return static_cast(typeId); } -bool cmpTagLt(const TiffComponent* lhs, const TiffComponent* rhs) { +bool cmpTagLt(const std::unique_ptr& lhs, const std::unique_ptr& rhs) { if (lhs->tag() != rhs->tag()) return lhs->tag() < rhs->tag(); return lhs->idx() < rhs->idx(); } -bool cmpGroupLt(const TiffComponent* lhs, const TiffComponent* rhs) { +bool cmpGroupLt(const std::unique_ptr& lhs, const std::unique_ptr& rhs) { return lhs->group() < rhs->group(); } diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 01d5109a59..911d4134ab 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -154,7 +154,7 @@ class TiffComponent { //! TiffComponent auto_ptr type using UniquePtr = std::unique_ptr; //! Container type to hold all metadata - using Components = std::vector; + using Components = std::vector>; //! @name Creators //@{ @@ -475,7 +475,7 @@ class TiffEntryBase : public TiffComponent { } //! Return a const pointer to the converted value of this component [[nodiscard]] const Value* pValue() const { - return pValue_; + return pValue_.get(); } //@} @@ -553,7 +553,7 @@ class TiffEntryBase : public TiffComponent { byte* pData_{}; //!< Pointer to the data area int idx_{}; //!< Unique id of the entry in the image - Value* pValue_{}; //!< Converted data value + std::unique_ptr pValue_{}; //!< Converted data value // This DataBuf is only used when TiffEntryBase::setData is called. // Otherwise, it remains empty. It is wrapped in a shared_ptr because @@ -919,7 +919,7 @@ class TiffDirectory : public TiffComponent { // DATA Components components_; //!< List of components in this directory bool hasNext_; //!< True if the directory has a next pointer - TiffComponent* pNext_{}; //!< Pointer to the next IFD + UniquePtr pNext_{}; //!< Pointer to the next IFD }; /*! @@ -989,7 +989,7 @@ class TiffSubIfd : public TiffEntryBase { private: //! A collection of TIFF directories (IFDs) - using Ifds = std::vector; + using Ifds = std::vector>; // DATA IfdId newGroup_; //!< Start of the range of group numbers for the sub-IFDs @@ -1470,13 +1470,13 @@ class TiffBinaryElement : public TiffEntryBase { @brief Compare two TIFF component pointers by tag. Return true if the tag of component lhs is less than that of rhs. */ -bool cmpTagLt(const TiffComponent* lhs, const TiffComponent* rhs); +bool cmpTagLt(const std::unique_ptr& lhs, const std::unique_ptr& rhs); /*! @brief Compare two TIFF component pointers by group. Return true if the group of component lhs is less than that of rhs. */ -bool cmpGroupLt(const TiffComponent* lhs, const TiffComponent* rhs); +bool cmpGroupLt(const std::unique_ptr& lhs, const std::unique_ptr& rhs); //! Function to create and initialize a new TIFF entry TiffComponent::UniquePtr newTiffEntry(uint16_t tag, IfdId group); diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index efceff1c37..610ce4a44f 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -580,8 +580,8 @@ void TiffEncoder::visitDirectory(TiffDirectory* /*object*/) { void TiffEncoder::visitDirectoryNext(TiffDirectory* object) { // Update type and count in IFD entries, in case they changed byte* p = object->start() + 2; - for (auto component : object->components_) { - p += updateDirEntry(p, byteOrder(), component); + for (auto& component : object->components_) { + p += updateDirEntry(p, byteOrder(), component.get()); } } From 3be906dbdefbe3369b2aef3aba9a140ba86eeaf9 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Wed, 19 Feb 2025 22:48:57 +0000 Subject: [PATCH 2/7] Code review suggestions from @neheb. --- src/tiffcomposite_int.cpp | 20 +++++--------------- src/tiffcomposite_int.hpp | 14 +++++++------- src/tiffvisitor_int.cpp | 2 +- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 854450344a..32d6a23fb1 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -89,14 +89,6 @@ TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arra // We'll figure out the correct cfg later } -TiffDirectory::~TiffDirectory() {} - -TiffSubIfd::~TiffSubIfd() {} - -TiffEntryBase::~TiffEntryBase() {} - -TiffBinaryArray::~TiffBinaryArray() {} - TiffEntryBase::TiffEntryBase(const TiffEntryBase& rhs) : TiffComponent(rhs), tiffType_(rhs.tiffType_), @@ -213,7 +205,7 @@ void TiffEntryBase::setValue(Value::UniquePtr value) { return; tiffType_ = toTiffType(value->typeId()); count_ = value->count(); - std::swap(pValue_, value); + pValue_ = std::move(value); } void TiffDataEntry::setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) { @@ -560,9 +552,8 @@ TiffComponent* TiffComponent::doAddChild(UniquePtr /*tiffComponent*/) { } // TiffComponent::doAddChild TiffComponent* TiffDirectory::doAddChild(TiffComponent::UniquePtr tiffComponent) { - TiffComponent* tc = tiffComponent.get(); components_.push_back(std::move(tiffComponent)); - return tc; + return components_.back().get(); } // TiffDirectory::doAddChild TiffComponent* TiffSubIfd::doAddChild(TiffComponent::UniquePtr tiffComponent) { @@ -588,10 +579,9 @@ TiffComponent* TiffIfdMakernote::doAddChild(TiffComponent::UniquePtr tiffCompone } TiffComponent* TiffBinaryArray::doAddChild(TiffComponent::UniquePtr tiffComponent) { - TiffComponent* tc = tiffComponent.get(); elements_.push_back(std::move(tiffComponent)); setDecoded(true); - return tc; + return elements_.back().get(); } // TiffBinaryArray::doAddChild TiffComponent* TiffComponent::addNext(TiffComponent::UniquePtr tiffComponent) { @@ -604,7 +594,7 @@ TiffComponent* TiffComponent::doAddNext(UniquePtr /*tiffComponent*/) { TiffComponent* TiffDirectory::doAddNext(TiffComponent::UniquePtr tiffComponent) { if (hasNext_) { - std::swap(pNext_, tiffComponent); + pNext_ = std::move(tiffComponent); return pNext_.get(); } return nullptr; @@ -1192,7 +1182,7 @@ size_t TiffComponent::writeImage(IoWrapper& ioWrapper, ByteOrder byteOrder) cons size_t TiffDirectory::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const { size_t len = 0; TiffComponent* pSubIfd = nullptr; - for (auto& component : components_) { + for (const auto& component : components_) { if (component->tag() == 0x014a) { // Hack: delay writing of sub-IFD image data to get the order correct #ifndef SUPPRESS_WARNINGS diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 911d4134ab..cb98e6f056 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -154,7 +154,7 @@ class TiffComponent { //! TiffComponent auto_ptr type using UniquePtr = std::unique_ptr; //! Container type to hold all metadata - using Components = std::vector>; + using Components = std::vector; //! @name Creators //@{ @@ -390,7 +390,7 @@ class TiffEntryBase : public TiffComponent { } //! Virtual destructor. - ~TiffEntryBase() override; + ~TiffEntryBase() override {}; //@} //! @name NOT implemented @@ -830,7 +830,7 @@ class TiffDirectory : public TiffComponent { //! Default constructor TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true); //! Virtual destructor - ~TiffDirectory() override; + ~TiffDirectory() override {}; //@} //! @name NOT implemented @@ -919,7 +919,7 @@ class TiffDirectory : public TiffComponent { // DATA Components components_; //!< List of components in this directory bool hasNext_; //!< True if the directory has a next pointer - UniquePtr pNext_{}; //!< Pointer to the next IFD + UniquePtr pNext_; //!< Pointer to the next IFD }; /*! @@ -938,7 +938,7 @@ class TiffSubIfd : public TiffEntryBase { //! Default constructor TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup); //! Virtual destructor - ~TiffSubIfd() override; + ~TiffSubIfd() override {}; //@} //! @name Protected Creators @@ -1269,7 +1269,7 @@ class TiffBinaryArray : public TiffEntryBase { //! Constructor for a complex binary array TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, size_t setSize, CfgSelFct cfgSelFct); //! Virtual destructor - ~TiffBinaryArray() override; + ~TiffBinaryArray() override {}; TiffBinaryArray& operator=(const TiffBinaryArray&) = delete; //@} @@ -1470,7 +1470,7 @@ class TiffBinaryElement : public TiffEntryBase { @brief Compare two TIFF component pointers by tag. Return true if the tag of component lhs is less than that of rhs. */ -bool cmpTagLt(const std::unique_ptr& lhs, const std::unique_ptr& rhs); +bool cmpTagLt(const TiffComponent::UniquePtr& lhs, const TiffComponent::UniquePtr& rhs); /*! @brief Compare two TIFF component pointers by group. Return true if the diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 610ce4a44f..1a06d02ab7 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -580,7 +580,7 @@ void TiffEncoder::visitDirectory(TiffDirectory* /*object*/) { void TiffEncoder::visitDirectoryNext(TiffDirectory* object) { // Update type and count in IFD entries, in case they changed byte* p = object->start() + 2; - for (auto& component : object->components_) { + for (const auto& component : object->components_) { p += updateDirEntry(p, byteOrder(), component.get()); } } From 754f98bee41cf0f5e56bd4798f557f7b58ffba1c Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Thu, 20 Feb 2025 14:39:02 +0000 Subject: [PATCH 3/7] Code review suggestions from @neheb. --- src/tiffcomposite_int.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index cb98e6f056..6c5738766f 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -390,7 +390,7 @@ class TiffEntryBase : public TiffComponent { } //! Virtual destructor. - ~TiffEntryBase() override {}; + ~TiffEntryBase() override = default; //@} //! @name NOT implemented @@ -553,7 +553,7 @@ class TiffEntryBase : public TiffComponent { byte* pData_{}; //!< Pointer to the data area int idx_{}; //!< Unique id of the entry in the image - std::unique_ptr pValue_{}; //!< Converted data value + std::unique_ptr pValue_; //!< Converted data value // This DataBuf is only used when TiffEntryBase::setData is called. // Otherwise, it remains empty. It is wrapped in a shared_ptr because @@ -830,7 +830,7 @@ class TiffDirectory : public TiffComponent { //! Default constructor TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true); //! Virtual destructor - ~TiffDirectory() override {}; + ~TiffDirectory() override = default; //@} //! @name NOT implemented @@ -938,7 +938,7 @@ class TiffSubIfd : public TiffEntryBase { //! Default constructor TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup); //! Virtual destructor - ~TiffSubIfd() override {}; + ~TiffSubIfd() override = default; //@} //! @name Protected Creators @@ -1269,7 +1269,7 @@ class TiffBinaryArray : public TiffEntryBase { //! Constructor for a complex binary array TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, size_t setSize, CfgSelFct cfgSelFct); //! Virtual destructor - ~TiffBinaryArray() override {}; + ~TiffBinaryArray() override = default; TiffBinaryArray& operator=(const TiffBinaryArray&) = delete; //@} From 168892348db03802903fdd3546490111b4c1332a Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Thu, 20 Feb 2025 14:40:22 +0000 Subject: [PATCH 4/7] clang-format --- src/tiffcomposite_int.hpp | 8 ++++---- src/tiffvisitor_int.cpp | 23 +++++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 6c5738766f..2a906b54bd 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -552,7 +552,7 @@ class TiffEntryBase : public TiffComponent { // storage_ DataBuf below. byte* pData_{}; //!< Pointer to the data area - int idx_{}; //!< Unique id of the entry in the image + int idx_{}; //!< Unique id of the entry in the image std::unique_ptr pValue_; //!< Converted data value // This DataBuf is only used when TiffEntryBase::setData is called. @@ -917,9 +917,9 @@ class TiffDirectory : public TiffComponent { //@} // DATA - Components components_; //!< List of components in this directory - bool hasNext_; //!< True if the directory has a next pointer - UniquePtr pNext_; //!< Pointer to the next IFD + Components components_; //!< List of components in this directory + bool hasNext_; //!< True if the directory has a next pointer + UniquePtr pNext_; //!< Pointer to the next IFD }; /*! diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 1a06d02ab7..af46a4a196 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -302,8 +302,7 @@ void TiffDecoder::decodeIptc(const TiffEntryBase* object) { return; } #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode IPTC block found in " - << "Directory Image, entry 0x83bb\n"; + EXV_WARNING << "Failed to decode IPTC block found in " << "Directory Image, entry 0x83bb\n"; #endif } @@ -324,8 +323,7 @@ void TiffDecoder::decodeIptc(const TiffEntryBase* object) { return; } #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode IPTC block found in " - << "Directory Image, entry 0x8649\n"; + EXV_WARNING << "Failed to decode IPTC block found in " << "Directory Image, entry 0x8649\n"; #endif } @@ -1229,8 +1227,7 @@ void TiffReader::readTiffEntry(TiffEntryBase* object) { if (p + 12 > pLast_) { #ifndef SUPPRESS_WARNINGS EXV_ERROR << "Entry in directory " << groupName(object->group()) - << "requests access to memory beyond the data buffer. " - << "Skipping entry.\n"; + << "requests access to memory beyond the data buffer. " << "Skipping entry.\n"; #endif return; } @@ -1284,9 +1281,8 @@ void TiffReader::readTiffEntry(TiffEntryBase* object) { } else { #ifndef SUPPRESS_WARNINGS EXV_ERROR << "Offset of directory " << groupName(object->group()) << ", entry 0x" << std::setw(4) - << std::setfill('0') << std::hex << object->tag() << " is out of bounds: " - << "Offset = 0x" << std::setw(8) << std::setfill('0') << std::hex << offset - << "; truncating the entry\n"; + << std::setfill('0') << std::hex << object->tag() << " is out of bounds: " << "Offset = 0x" + << std::setw(8) << std::setfill('0') << std::hex << offset << "; truncating the entry\n"; #endif } size = 0; @@ -1302,11 +1298,10 @@ void TiffReader::readTiffEntry(TiffEntryBase* object) { // check for size being invalid if (size > static_cast(pLast_ - pData)) { #ifndef SUPPRESS_WARNINGS - EXV_ERROR << "Upper boundary of data for " - << "directory " << groupName(object->group()) << ", entry 0x" << std::setw(4) << std::setfill('0') - << std::hex << object->tag() << " is out of bounds: " - << "Offset = 0x" << std::setw(8) << std::setfill('0') << std::hex << offset << ", size = " << std::dec - << size + EXV_ERROR << "Upper boundary of data for " << "directory " << groupName(object->group()) << ", entry 0x" + << std::setw(4) << std::setfill('0') << std::hex << object->tag() + << " is out of bounds: " << "Offset = 0x" << std::setw(8) << std::setfill('0') << std::hex << offset + << ", size = " << std::dec << size << ", exceeds buffer size by " // cast to make MSVC happy << size - static_cast(pLast_ - pData) << " Bytes; truncating the entry\n"; From 83312578f988f12e7b6f9509d2a6f90b6c262fad Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Thu, 20 Feb 2025 14:50:03 +0000 Subject: [PATCH 5/7] Use emplace_back() --- src/tiffcomposite_int.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 32d6a23fb1..208e8be400 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -562,7 +562,7 @@ TiffComponent* TiffSubIfd::doAddChild(TiffComponent::UniquePtr tiffComponent) { throw Error(ErrorCode::kerErrorMessage, "dynamic_cast to TiffDirectory failed"); } tiffComponent.release(); - ifds_.push_back(std::unique_ptr(d)); + ifds_.emplace_back(d); return d; } // TiffSubIfd::doAddChild From ff65bbb64e37c60002d7c446ec672ce1ef1fb839 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Thu, 20 Feb 2025 15:17:38 +0000 Subject: [PATCH 6/7] Move TiffIfdMakernote destructor to .cpp file to fix a build error caused by the header file not being to able to see the definition of MnHeader. --- src/tiffcomposite_int.cpp | 3 +++ src/tiffcomposite_int.hpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 208e8be400..b5786591d0 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -75,6 +75,9 @@ TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, std TiffComponent(tag, group), pHeader_(std::move(pHeader)), ifd_(tag, mnGroup, hasNext) { } +TiffIfdMakernote::~TiffIfdMakernote() { +} + TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg& arrayCfg, const ArrayDef* arrayDef, size_t defSize) : TiffEntryBase(tag, group, arrayCfg.elTiffType_), arrayCfg_(&arrayCfg), arrayDef_(arrayDef), defSize_(defSize) { diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 2a906b54bd..c583397b79 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -1073,7 +1073,7 @@ class TiffIfdMakernote : public TiffComponent { //! Default constructor TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, std::unique_ptr pHeader, bool hasNext = true); //! Virtual destructor - ~TiffIfdMakernote() override = default; + ~TiffIfdMakernote() override; //@} /*! From 52925b836d87026cfb0cc9ef47afe3ad9d323667 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Thu, 20 Feb 2025 18:58:39 +0000 Subject: [PATCH 7/7] Code review suggestion from @neheb. --- src/tiffcomposite_int.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index b5786591d0..3d38b99e6a 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -75,8 +75,7 @@ TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, std TiffComponent(tag, group), pHeader_(std::move(pHeader)), ifd_(tag, mnGroup, hasNext) { } -TiffIfdMakernote::~TiffIfdMakernote() { -} +TiffIfdMakernote::~TiffIfdMakernote() = default; TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg& arrayCfg, const ArrayDef* arrayDef, size_t defSize) :