From: Chong Yidong Date: Tue, 23 Jun 2009 14:14:40 +0000 (+0000) Subject: * src/ftfont.c (setup_otf_gstring, ftfont_shape_by_flt): Use X-Git-Tag: emacs-pretest-23.0.96~87 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c736632e7b6f25f51d23333826bae3e340d1aee6;p=emacs.git * src/ftfont.c (setup_otf_gstring, ftfont_shape_by_flt): Use xmalloc and xrealloc (not malloc and realloc), so subsequent heap pointer dereferences are guaranteed to be valid. --- diff --git a/src/ChangeLog b/src/ChangeLog index 840a0b7b1f6..e3ae8805235 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-06-23 Jim Meyering + + * src/ftfont.c (setup_otf_gstring, ftfont_shape_by_flt): Use + xmalloc and xrealloc (not malloc and realloc), so subsequent heap + pointer dereferences are guaranteed to be valid. + 2009-06-21 Jason Rumney * w32term.c (keyboard_codepage): New static variable. diff --git a/src/ftfont.c b/src/ftfont.c index 7dcdee61ab4..25545d1a08f 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1700,12 +1700,12 @@ setup_otf_gstring (int size) { if (otf_gstring.size == 0) { - otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * size); + otf_gstring.glyphs = (OTF_Glyph *) xmalloc (sizeof (OTF_Glyph) * size); otf_gstring.size = size; } else if (otf_gstring.size < size) { - otf_gstring.glyphs = (OTF_Glyph *) realloc (otf_gstring.glyphs, + otf_gstring.glyphs = (OTF_Glyph *) xrealloc (otf_gstring.glyphs, sizeof (OTF_Glyph) * size); otf_gstring.size = size; } @@ -2037,13 +2037,13 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf) { gstring.allocated = len * 2; gstring.glyph_size = sizeof (MFLTGlyph); - gstring.glyphs = malloc (sizeof (MFLTGlyph) * gstring.allocated); + gstring.glyphs = xmalloc (sizeof (MFLTGlyph) * gstring.allocated); } else if (gstring.allocated < len * 2) { gstring.allocated = len * 2; - gstring.glyphs = realloc (gstring.glyphs, - sizeof (MFLTGlyph) * gstring.allocated); + gstring.glyphs = xrealloc (gstring.glyphs, + sizeof (MFLTGlyph) * gstring.allocated); } memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); for (i = 0; i < len; i++) @@ -2092,7 +2092,7 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf) if (result != -2) break; gstring.allocated += gstring.allocated; - gstring.glyphs = realloc (gstring.glyphs, + gstring.glyphs = xrealloc (gstring.glyphs, sizeof (MFLTGlyph) * gstring.allocated); } if (gstring.used > LGSTRING_GLYPH_LEN (lgstring))