File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
src/java.desktop/macosx/native/libawt_lwawt/font Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -974,23 +974,28 @@ @implementation CGGI_GlyphCanvas
974
974
return ;
975
975
}
976
976
977
- // just do one malloc, and carve it up for all the buffers
978
- void *buffer = malloc ((sizeof (CGRect) + sizeof (CGSize) + sizeof (CGGlyph) + sizeof (UnicodeScalarValue)) * len);
979
- if (buffer == NULL ) {
977
+ CGRect *bboxes = (CGRect*)calloc (len, sizeof (CGRect));
978
+ CGSize *advances = (CGSize*)calloc (len, sizeof (CGSize));
979
+ CGGlyph *glyphs = (CGGlyph*)calloc (len, sizeof (CGGlyph));
980
+ UnicodeScalarValue *uniChars = (UnicodeScalarValue*)calloc (len, sizeof (UnicodeScalarValue));
981
+
982
+ if (bboxes == NULL || advances == NULL || glyphs == NULL || uniChars == NULL ) {
983
+ free (bboxes);
984
+ free (advances);
985
+ free (glyphs);
986
+ free (uniChars);
980
987
[[NSException exceptionWithName: NSMallocException
981
988
reason: @" Failed to allocate memory for the temporary glyph strike and measurement buffers." userInfo: nil ] raise ];
982
989
}
983
990
984
- CGRect *bboxes = (CGRect *)(buffer);
985
- CGSize *advances = (CGSize *)(bboxes + sizeof (CGRect) * len);
986
- CGGlyph *glyphs = (CGGlyph *)(advances + sizeof (CGGlyph) * len);
987
- UnicodeScalarValue *uniChars = (UnicodeScalarValue *)(glyphs + sizeof (UnicodeScalarValue) * len);
988
-
989
991
CGGI_CreateGlyphsAndScanForComplexities (glyphInfos, strike, &mode,
990
992
rawGlyphCodes, uniChars, glyphs,
991
993
advances, bboxes, len);
992
994
993
- free (buffer);
995
+ free (bboxes);
996
+ free (advances);
997
+ free (glyphs);
998
+ free (uniChars);
994
999
}
995
1000
996
1001
#define TX_FIXED_UNSAFE (v ) (isinf(v) || isnan(v) || fabs(v) >= (1 <<30 ))
You can’t perform that action at this time.
0 commit comments