Skip to content

Commit

Permalink
Fixed bug about PSD with the 6 hierarchy or more.
Browse files Browse the repository at this point in the history
Fixed bug to fail to load PSD which has the 6 hierarchy or more.
  • Loading branch information
hidefuku committed Apr 29, 2017
1 parent eadeba7 commit a10d877
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/img/PSDReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,9 @@ bool PSDReader::loadLayerAndMaskInfo()

#if 0
// entry temp setting
if (layer.name.size() >= 3 && layer.name.at(0) == '<' && layer.name.at(1) == '/' && layer.name.back() == '>')
if (layer->name == "</Layer group>")
{
layer.entryType = PSDFormat::LayerEntryType_Bounding;
}
else
{
layer.entryType = ((layer.flags & 0x10) != 0) ? PSDFormat::LayerEntryType_CloseFolder : PSDFormat::LayerEntryType_Layer;
layer->entryType = PSDFormat::LayerEntryType_Bounding;
}
#endif
// additional layer info
Expand Down Expand Up @@ -632,6 +628,7 @@ bool PSDReader::loadAdditionalLayerInfo(
aLayer->entryType = (PSDFormat::LayerEntryType)readUInt32();
if (checkFailure()) return false;

// check value validity
if (aLayer->entryType >= PSDFormat::LayerEntryType_TERM)
{
mSection += "/additional layer info/section divider setting/entry";
Expand All @@ -646,6 +643,8 @@ bool PSDReader::loadAdditionalLayerInfo(
// signature
std::string signature = readString(4);
if (checkFailure()) return false;

// check value validity
if (signature != "8BIM")
{
mSection += "/additional layer info/signature/section divider setting/signature";
Expand All @@ -659,6 +658,26 @@ bool PSDReader::loadAdditionalLayerInfo(

skipTo(dataBeginPos);
}
else if (aLayer && info->key == "lsdk" && info->dataLength >= 4)
{ //Nested Section divider setting (Undocumented option)

std::ios::pos_type dataBeginPos = tellg();
// entry
aLayer->entryType = (PSDFormat::LayerEntryType)readUInt32();
if (checkFailure()) return false;

// check value validity
if (aLayer->entryType >= PSDFormat::LayerEntryType_TERM)
{
mSection += "/additional layer info/nested section divider setting/entry";
mValue = std::to_string(aLayer->entryType);
mResultCode = ResultCode_InvalidValue;
return false;
}
if (checkFailure()) return false;

skipTo(dataBeginPos);
}

// read as a raw data
info->data.reset(new uint8[info->dataLength]);
Expand Down

0 comments on commit a10d877

Please sign in to comment.