Merge pull request #1455 from harfbuzz/cff-strinc_assert

[CFF] fix oss-fuzz issue 11675 (ASSERT: count <= str.len)
This commit is contained in:
Behdad Esfahbod 2018-12-05 15:37:15 -08:00 committed by GitHub
commit 81cfd3c775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -391,8 +391,22 @@ struct SubByteStr
inline operator ByteStr (void) const { return ByteStr (str, offset, str.len - offset); }
inline bool avail (unsigned int count=1) const { return str.check_limit (offset, count); }
inline void inc (unsigned int count=1) { offset += count; assert (count <= str.len); }
inline bool avail (unsigned int count=1) const
{
return (!in_error () && str.check_limit (offset, count));
}
inline void inc (unsigned int count=1)
{
if (likely (!in_error () && (offset <= str.len) && (offset + count <= str.len)))
{
offset += count;
}
else
{
offset = str.len;
set_error ();
}
}
inline void set_error (void) { error = true; }
inline bool in_error (void) const { return error; }