Kaynağa Gözat

Zero-length allocation fix for font glyph sheet

Bill Robinson 12 yıl önce
ebeveyn
işleme
15dbc3e0b2
1 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. 5 3
      Core/Contents/Source/PolyFontGlyphSheet.cpp

+ 5 - 3
Core/Contents/Source/PolyFontGlyphSheet.cpp

@@ -156,10 +156,12 @@ void FontGlyphSheet::buildGlyphs(std::set<wchar_t> characters) {
 			gd.size_x = slot->bitmap.width;
 			gd.size_y = slot->bitmap.rows;
 			gd.advance.set(Number(slot->advance.x)/(64<<shift), Number(slot->advance.y)/(64<<shift));
-			int dataLength = slot->bitmap.pitch * gd.size_y;
-			gd.data = new unsigned char[dataLength];
 			gd.pitch = slot->bitmap.pitch;
-			memcpy(gd.data, slot->bitmap.buffer, dataLength);
+			int dataLength = slot->bitmap.pitch * gd.size_y;
+			if (dataLength) {
+				gd.data = new unsigned char[dataLength];
+				memcpy(gd.data, slot->bitmap.buffer, dataLength);
+			}
 		}
 	}