fix FontDirWrapper off-by-one bugs and warnings

This commit is contained in:
Cameron Kaiser 2017-07-24 21:20:51 -07:00
parent 797260262e
commit 51e6a2cf9f
2 changed files with 4 additions and 4 deletions

View File

@ -136,7 +136,7 @@ gfxPlatformMac::GetCachedDirForFont(nsString name)
void
gfxPlatformMac::SetCachedDirForFont(nsString name, uint8_t* table, ByteCount sizer)
{
if (sizer < 0 || sizer > 1024) return;
if (MOZ_UNLIKELY(sizer < 1 || sizer > 1023)) return;
FontDirWrapper *k = new FontDirWrapper(sizer, table);
PlatformFontDirCache.Put(name, k);

View File

@ -26,12 +26,12 @@ class FontDirWrapper {
public:
uint8_t fontDir[1024];
ByteCount sizer;
FontDirWrapper::FontDirWrapper(ByteCount sized, uint8_t *dir) {
if (sized < 0 || sized > 1024) return;
FontDirWrapper(ByteCount sized, uint8_t *dir) {
if (MOZ_UNLIKELY(sized < 1 || sized > 1023)) return;
sizer = sized;
memcpy(fontDir, dir, sizer);
}
FontDirWrapper::~FontDirWrapper() { }
~FontDirWrapper() { }
};
class gfxPlatformMac : public gfxPlatform {