aboutsummaryrefslogtreecommitdiff
path: root/libXfont/src/fontfile/fontdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'libXfont/src/fontfile/fontdir.c')
-rw-r--r--libXfont/src/fontfile/fontdir.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libXfont/src/fontfile/fontdir.c b/libXfont/src/fontfile/fontdir.c
index ef7ffa561..7271603ec 100644
--- a/libXfont/src/fontfile/fontdir.c
+++ b/libXfont/src/fontfile/fontdir.c
@@ -177,6 +177,11 @@ FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
if (table->sorted)
return (FontEntryPtr) 0; /* "cannot" happen */
if (table->used == table->size) {
+ if (table->size >= ((INT32_MAX / sizeof(FontEntryRec)) - 100))
+ /* If we've read so many entries we're going to ask for 2gb
+ or more of memory, something is so wrong with this font
+ directory that we should just give up before we overflow. */
+ return NULL;
newsize = table->size + 100;
entry = realloc(table->entries, newsize * sizeof(FontEntryRec));
if (!entry)