Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for 1.2.4 #9

Open
wants to merge 2 commits into
base: origin-1.2.4-1733554831
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/FeatureMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ bool FeatureMap::readFeats(const Face & face)
label, uiName, flags,
uiSet, num_settings);
}
m_defaultFeatures = new Features(bits/(sizeof(uint32)*8) + 1, *this);
new (&m_defaultFeatures) Features(bits/(sizeof(uint32)*8) + 1, *this);
m_pNamedFeats = new NameAndFeatureRef[m_numFeats];
if (!m_defaultFeatures || !m_pNamedFeats)
if (!m_pNamedFeats)
{
free(defVals);
return false;
}
for (int i = 0; i < m_numFeats; ++i)
{
m_feats[i].applyValToFeature(defVals[i], *m_defaultFeatures);
m_feats[i].applyValToFeature(defVals[i], m_defaultFeatures);
m_pNamedFeats[i] = m_feats+i;
}

Expand Down Expand Up @@ -214,7 +214,7 @@ bool SillMap::readSill(const Face & face)
uint16 numSettings = be::read<uint16>(p);
uint16 offset = be::read<uint16>(p);
if (offset + 8U * numSettings > sill.size() && numSettings > 0) return false;
Features* feats = new Features(*m_FeatureMap.m_defaultFeatures);
Features* feats = new Features(m_FeatureMap.m_defaultFeatures);
if (!feats) return false;
const byte *pLSet = sill + offset;

Expand Down Expand Up @@ -250,7 +250,7 @@ Features* SillMap::cloneFeatures(uint32 langname/*0 means default*/) const
return new Features(*m_langFeats[i].m_pFeatures);
}
}
return new Features (*m_FeatureMap.m_defaultFeatures);
return new Features (m_FeatureMap.m_defaultFeatures);
}


Expand Down
7 changes: 4 additions & 3 deletions src/SegCacheEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ SegCacheEntry::SegCacheEntry(const uint16* cmapGlyphs, size_t length, Segment *
}
const Slot * slot = seg->first();
m_glyph = new Slot[glyphCount];
m_attr = gralloc<int16>(glyphCount * seg->numAttrs());
int attrSize = seg->numAttrs() + (seg->hasCollisionInfo() ? (sizeof(SlotCollision) + 1) / 2 : 0);
m_attr = gralloc<int16>(glyphCount * attrSize);
if (!m_glyph || (!m_attr && seg->numAttrs())) return;
m_glyphLength = glyphCount;
Slot * slotCopy = m_glyph;
Expand All @@ -70,9 +71,9 @@ SegCacheEntry::SegCacheEntry(const uint16* cmapGlyphs, size_t length, Segment *
uint16 pos = 0;
while (slot)
{
slotCopy->userAttrs(m_attr + pos * seg->numAttrs());
slotCopy->userAttrs(m_attr + pos * attrSize);
slotCopy->m_justs = m_justs ? reinterpret_cast<SlotJustify *>(m_justs + justs_pos++ * sizeof_sjust) : 0;
slotCopy->set(*slot, -static_cast<int32>(charOffset), seg->numAttrs(), seg->silf()->numJustLevels(), length);
slotCopy->set(*slot, -static_cast<int32>(charOffset), attrSize, seg->silf()->numJustLevels(), length);
slotCopy->index(pos);
if (slot->firstChild())
slotCopy->m_child = m_glyph + slot->firstChild()->index();
Expand Down
4 changes: 2 additions & 2 deletions src/TtfUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ size_t LocaLookup(gid16 nGlyphId,
// CheckTable verifies the index_to_loc_format is valid
if (be::swap(pTable->index_to_loc_format) == Sfnt::FontHeader::ShortIndexLocFormat)
{ // loca entries are two bytes and have been divided by two
if (nGlyphId < (lLocaSize >> 1) - 1) // allow sentinel value to be accessed
if (lLocaSize > 1 && nGlyphId + 1u < lLocaSize >> 1) // allow sentinel value to be accessed
{
const uint16 * pShortTable = reinterpret_cast<const uint16 *>(pLoca);
return (be::peek<uint16>(pShortTable + nGlyphId) << 1);
Expand All @@ -1158,7 +1158,7 @@ size_t LocaLookup(gid16 nGlyphId,

if (be::swap(pTable->index_to_loc_format) == Sfnt::FontHeader::LongIndexLocFormat)
{ // loca entries are four bytes
if (nGlyphId < (lLocaSize >> 2) - 1)
if (lLocaSize > 3 && nGlyphId + 1u < lLocaSize >> 2)
{
const uint32 * pLongTable = reinterpret_cast<const uint32 *>(pLoca);
return be::peek<uint32>(pLongTable + nGlyphId);
Expand Down
Loading