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 @@ -893,23 +893,28 @@ @implementation CGGI_GlyphCanvas
893
893
return ;
894
894
}
895
895
896
- // just do one malloc, and carve it up for all the buffers
897
- void *buffer = malloc ((sizeof (CGRect) + sizeof (CGSize) + sizeof (CGGlyph) + sizeof (UnicodeScalarValue)) * len);
898
- if (buffer == NULL ) {
896
+ CGRect *bboxes = (CGRect*)calloc (len, sizeof (CGRect));
897
+ CGSize *advances = (CGSize*)calloc (len, sizeof (CGSize));
898
+ CGGlyph *glyphs = (CGGlyph*)calloc (len, sizeof (CGGlyph));
899
+ UnicodeScalarValue *uniChars = (UnicodeScalarValue*)calloc (len, sizeof (UnicodeScalarValue));
900
+
901
+ if (bboxes == NULL || advances == NULL || glyphs == NULL || uniChars == NULL ) {
902
+ free (bboxes);
903
+ free (advances);
904
+ free (glyphs);
905
+ free (uniChars);
899
906
[[NSException exceptionWithName: NSMallocException
900
907
reason: @" Failed to allocate memory for the temporary glyph strike and measurement buffers." userInfo: nil ] raise ];
901
908
}
902
909
903
- CGRect *bboxes = (CGRect *)(buffer);
904
- CGSize *advances = (CGSize *)(bboxes + sizeof (CGRect) * len);
905
- CGGlyph *glyphs = (CGGlyph *)(advances + sizeof (CGGlyph) * len);
906
- UnicodeScalarValue *uniChars = (UnicodeScalarValue *)(glyphs + sizeof (UnicodeScalarValue) * len);
907
-
908
910
CGGI_CreateGlyphsAndScanForComplexities (glyphInfos, strike, &mode,
909
911
rawGlyphCodes, uniChars, glyphs,
910
912
advances, bboxes, len);
911
913
912
- free (buffer);
914
+ free (bboxes);
915
+ free (advances);
916
+ free (glyphs);
917
+ free (uniChars);
913
918
}
914
919
915
920
#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