diff options
author | Jim Meyering <jim@meyering.net> | 2009-06-23 06:49:20 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2009-06-23 06:49:20 +0000 |
commit | c6da7cd2b63cc9094d690b74875bf8609b5c0107 (patch) | |
tree | 4c6731024ab0f50692ceb0b848492a3b77b1bdcf /src/ftfont.c | |
parent | f5f20f6c6718e08c1c8c9140466c7eb5811fe467 (diff) | |
download | emacs-c6da7cd2b63cc9094d690b74875bf8609b5c0107.tar.gz |
Don't dereference NULL upon failed malloc and realloc.
* 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.
Diffstat (limited to 'src/ftfont.c')
-rw-r--r-- | src/ftfont.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ftfont.c b/src/ftfont.c index 695579a05f8..70c1797dce0 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1700,13 +1700,13 @@ 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, - sizeof (OTF_Glyph) * size); + otf_gstring.glyphs = xrealloc (otf_gstring.glyphs, + sizeof (OTF_Glyph) * size); otf_gstring.size = size; } otf_gstring.used = 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,8 +2092,8 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf) if (result != -2) break; gstring.allocated += gstring.allocated; - gstring.glyphs = realloc (gstring.glyphs, - sizeof (MFLTGlyph) * gstring.allocated); + gstring.glyphs = xrealloc (gstring.glyphs, + sizeof (MFLTGlyph) * gstring.allocated); } if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) return Qnil; |