Skip to content

Commit

Permalink
Initialize a non-empty PNG ICC profile name
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Sep 15, 2022
1 parent d2253c9 commit 7715493
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/exiv2/pngimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EXIV2API PngImage : public Image {
void doWriteMetadata(BasicIo& outIo);
//@}

std::string profileName_;
std::string profileName_{"ICC Profile"};

}; // class PngImage

Expand Down
7 changes: 5 additions & 2 deletions src/pngimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,16 @@ void PngImage::readMetadata() {
enforce(iccOffset < 80 && iccOffset < chunkLength, Exiv2::ErrorCode::kerCorruptedMetadata);
} while (chunkData.read_uint8(iccOffset++) != 0x00);

profileName_ = std::string(chunkData.c_str(), iccOffset - 1);
// Don't fail on empty ICC profile name, but also don't overwrite the default
std::string profileName = std::string(chunkData.c_str(), iccOffset - 1);
if (profileName.size() > 0)
profileName_ = profileName;
++iccOffset; // +1 = 'compressed' flag
enforce(iccOffset <= chunkLength, Exiv2::ErrorCode::kerCorruptedMetadata);

zlibToDataBuf(chunkData.c_data(iccOffset), static_cast<uLongf>(chunkLength - iccOffset), iccProfile_);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::readMetadata: profile name: " << profileName_ << std::endl;
std::cout << "Exiv2::PngImage::readMetadata: profile name: " << profileName << std::endl;
std::cout << "Exiv2::PngImage::readMetadata: iccProfile.size_ (uncompressed) : " << iccProfile_.size()
<< std::endl;
#endif
Expand Down

0 comments on commit 7715493

Please sign in to comment.