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 13cda0a37..a4d41960b 100644
--- a/libXfont/src/fontfile/fontdir.c
+++ b/libXfont/src/fontfile/fontdir.c
@@ -179,6 +179,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)