Skip to content

Commit

Permalink
[otlayout] Avoid invalid access with Context format 3
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Dec 13, 2014
1 parent 295ef1d commit 9df0a52
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hb-ot-layout-gsubgpos-private.hh
Expand Up @@ -1498,6 +1498,7 @@ struct ContextFormat3
TRACE_SANITIZE (this);
if (!c->check_struct (this)) return TRACE_RETURN (false);
unsigned int count = glyphCount;
if (!count) return TRACE_RETURN (false); /* We want to access coverage[0] freely. */
if (!c->check_array (coverage, coverage[0].static_size, count)) return TRACE_RETURN (false);
for (unsigned int i = 0; i < count; i++)
if (!coverage[i].sanitize (c, this)) return TRACE_RETURN (false);
Expand Down Expand Up @@ -2109,6 +2110,7 @@ struct ChainContextFormat3
if (!backtrack.sanitize (c, this)) return TRACE_RETURN (false);
OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!input.sanitize (c, this)) return TRACE_RETURN (false);
if (!input.len) return TRACE_RETURN (false); /* To be consistent with Context. */
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
if (!lookahead.sanitize (c, this)) return TRACE_RETURN (false);
ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
Expand Down

0 comments on commit 9df0a52

Please sign in to comment.