from encode_int removed assert hit by fuzzer

clamp the value instead
This commit is contained in:
Michiharu Ariza 2018-10-12 14:14:21 -07:00
parent fc0153a1d4
commit b64ef69b9e
1 changed files with 4 additions and 1 deletions

View File

@ -59,7 +59,10 @@ struct ByteStrBuff : hb_vector_t<char, 1>
return encode_byte ((v >> 8) + OpCode_TwoByteNegInt0) && encode_byte (v & 0xFF);
}
}
assert ((-32768 <= v) && (v <= 32767));
if (unlikely (v < -32768))
v = -32768;
else if (unlikely (v > 32767))
v = 32767;
return encode_byte (OpCode_shortint) &&
encode_byte ((v >> 8) & 0xFF) &&
encode_byte (v & 0xFF);