aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nx-X11/lib/font/fontfile/fontdir.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/nx-X11/lib/font/fontfile/fontdir.c b/nx-X11/lib/font/fontfile/fontdir.c
index 8f75d8bde..899ff05ef 100644
--- a/nx-X11/lib/font/fontfile/fontdir.c
+++ b/nx-X11/lib/font/fontfile/fontdir.c
@@ -185,6 +185,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 = (FontEntryPtr) xrealloc(table->entries,
newsize * sizeof(FontEntryRec));