Fix undefined shifts in ReadableFontData::ReadShort.
Shifting a negative value is undefined behavior.
Fixes https://crbug.com/655914
diff --git a/cpp/src/sfntly/data/readable_font_data.cc b/cpp/src/sfntly/data/readable_font_data.cc
index 93678ff..07a0db6 100644
--- a/cpp/src/sfntly/data/readable_font_data.cc
+++ b/cpp/src/sfntly/data/readable_font_data.cc
@@ -111,7 +111,9 @@
int32_t b2 = ReadUByte(index + 1);
if (b2 < 0)
return kInvalidShort;
- return ((b1 << 8 | b2) << 16) >> 16;
+
+ uint32_t result = static_cast<uint32_t>(b1) << 8 | b2;
+ return static_cast<int32_t>(result << 16) >> 16;
}
int32_t ReadableFontData::ReadUInt24(int32_t index) {