diff options
Diffstat (limited to 'src/ftfont.c')
| -rw-r--r-- | src/ftfont.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/ftfont.c b/src/ftfont.c index 4e313a89021..7858a31be21 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -214,6 +214,10 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) | |||
| 214 | 214 | ||
| 215 | for (i = 0; i < FONT_OBJLIST_INDEX; i++) | 215 | for (i = 0; i < FONT_OBJLIST_INDEX; i++) |
| 216 | ASET (val, i, AREF (entity, i)); | 216 | ASET (val, i, AREF (entity, i)); |
| 217 | |||
| 218 | ASET (val, FONT_EXTRA_INDEX, Fcopy_sequence (extra)); | ||
| 219 | font_put_extra (val, QCfont_entity, key); | ||
| 220 | |||
| 217 | return val; | 221 | return val; |
| 218 | } | 222 | } |
| 219 | entity = font_make_entity (); | 223 | entity = font_make_entity (); |
| @@ -682,7 +686,10 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec) | |||
| 682 | if (NILP (val)) | 686 | if (NILP (val)) |
| 683 | continue; | 687 | continue; |
| 684 | len = Flength (val); | 688 | len = Flength (val); |
| 685 | spec->features[i] = malloc (sizeof (int) * XINT (len)); | 689 | spec->features[i] = |
| 690 | (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len) | ||
| 691 | ? 0 | ||
| 692 | : malloc (sizeof (int) * XINT (len))); | ||
| 686 | if (! spec->features[i]) | 693 | if (! spec->features[i]) |
| 687 | { | 694 | { |
| 688 | if (i > 0 && spec->features[0]) | 695 | if (i > 0 && spec->features[0]) |
| @@ -1761,15 +1768,10 @@ static OTF_GlyphString otf_gstring; | |||
| 1761 | static void | 1768 | static void |
| 1762 | setup_otf_gstring (int size) | 1769 | setup_otf_gstring (int size) |
| 1763 | { | 1770 | { |
| 1764 | if (otf_gstring.size == 0) | 1771 | if (otf_gstring.size < size) |
| 1765 | { | ||
| 1766 | otf_gstring.glyphs = (OTF_Glyph *) xmalloc (sizeof (OTF_Glyph) * size); | ||
| 1767 | otf_gstring.size = size; | ||
| 1768 | } | ||
| 1769 | else if (otf_gstring.size < size) | ||
| 1770 | { | 1772 | { |
| 1771 | otf_gstring.glyphs = xrealloc (otf_gstring.glyphs, | 1773 | otf_gstring.glyphs = xnrealloc (otf_gstring.glyphs, |
| 1772 | sizeof (OTF_Glyph) * size); | 1774 | size, sizeof (OTF_Glyph)); |
| 1773 | otf_gstring.size = size; | 1775 | otf_gstring.size = size; |
| 1774 | } | 1776 | } |
| 1775 | otf_gstring.used = size; | 1777 | otf_gstring.used = size; |
| @@ -2445,17 +2447,19 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, | |||
| 2445 | } | 2447 | } |
| 2446 | } | 2448 | } |
| 2447 | 2449 | ||
| 2450 | if (INT_MAX / 2 < len) | ||
| 2451 | memory_full (SIZE_MAX); | ||
| 2452 | |||
| 2448 | if (gstring.allocated == 0) | 2453 | if (gstring.allocated == 0) |
| 2449 | { | 2454 | { |
| 2450 | gstring.allocated = len * 2; | ||
| 2451 | gstring.glyph_size = sizeof (MFLTGlyph); | 2455 | gstring.glyph_size = sizeof (MFLTGlyph); |
| 2452 | gstring.glyphs = xmalloc (sizeof (MFLTGlyph) * gstring.allocated); | 2456 | gstring.glyphs = xnmalloc (len * 2, sizeof (MFLTGlyph)); |
| 2457 | gstring.allocated = len * 2; | ||
| 2453 | } | 2458 | } |
| 2454 | else if (gstring.allocated < len * 2) | 2459 | else if (gstring.allocated < len * 2) |
| 2455 | { | 2460 | { |
| 2461 | gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, sizeof (MFLTGlyph)); | ||
| 2456 | gstring.allocated = len * 2; | 2462 | gstring.allocated = len * 2; |
| 2457 | gstring.glyphs = xrealloc (gstring.glyphs, | ||
| 2458 | sizeof (MFLTGlyph) * gstring.allocated); | ||
| 2459 | } | 2463 | } |
| 2460 | memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); | 2464 | memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); |
| 2461 | for (i = 0; i < len; i++) | 2465 | for (i = 0; i < len; i++) |
| @@ -2504,9 +2508,11 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, | |||
| 2504 | int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt); | 2508 | int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt); |
| 2505 | if (result != -2) | 2509 | if (result != -2) |
| 2506 | break; | 2510 | break; |
| 2507 | gstring.allocated += gstring.allocated; | 2511 | if (INT_MAX / 2 < gstring.allocated) |
| 2508 | gstring.glyphs = xrealloc (gstring.glyphs, | 2512 | memory_full (SIZE_MAX); |
| 2509 | sizeof (MFLTGlyph) * gstring.allocated); | 2513 | gstring.glyphs = xnrealloc (gstring.glyphs, |
| 2514 | gstring.allocated, 2 * sizeof (MFLTGlyph)); | ||
| 2515 | gstring.allocated *= 2; | ||
| 2510 | } | 2516 | } |
| 2511 | if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) | 2517 | if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) |
| 2512 | return Qnil; | 2518 | return Qnil; |