Mercurial > emacs
changeset 53334:0432020d46a7
(cache_face): Abort if c->size exceeds MAX_FACE_ID.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sun, 28 Dec 2003 00:12:45 +0000 |
parents | c23cf5520cd9 |
children | fe80edbc3909 |
files | src/xfaces.c |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xfaces.c Sun Dec 28 00:12:27 2003 +0000 +++ b/src/xfaces.c Sun Dec 28 00:12:45 2003 +0000 @@ -5577,12 +5577,19 @@ face->id = i; /* Maybe enlarge C->faces_by_id. */ - if (i == c->used && c->used == c->size) - { - int new_size = 2 * c->size; - int sz = new_size * sizeof *c->faces_by_id; - c->faces_by_id = (struct face **) xrealloc (c->faces_by_id, sz); - c->size = new_size; + if (i == c->used) + { + if (c->used == c->size) + { + int new_size, sz; + new_size = min (2 * c->size, MAX_FACE_ID); + if (new_size == c->size) + abort (); /* Alternatives? ++kfs */ + sz = new_size * sizeof *c->faces_by_id; + c->faces_by_id = (struct face **) xrealloc (c->faces_by_id, sz); + c->size = new_size; + } + c->used++; } #if GLYPH_DEBUG @@ -5601,8 +5608,6 @@ #endif /* GLYPH_DEBUG */ c->faces_by_id[i] = face; - if (i == c->used) - ++c->used; }