summaryrefslogtreecommitdiff
path: root/src/fontfile
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2019-08-03 19:09:19 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2019-08-03 19:31:14 -0700
commitf54470dab5b392380df61a22b4b4bef685b6cee2 (patch)
tree561d2a367f295f3fe53f72712b3b3f3d1011ec18 /src/fontfile
parent27207d35d4b4bbd5d2b2c5f7e13a61ea43d04a4a (diff)
Convert multiplying realloc calls to use reallocarray instead
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/fontfile')
-rw-r--r--src/fontfile/bitsource.c3
-rw-r--r--src/fontfile/catalogue.c4
-rw-r--r--src/fontfile/fontdir.c2
-rw-r--r--src/fontfile/fontscale.c3
-rw-r--r--src/fontfile/renderers.c3
5 files changed, 10 insertions, 5 deletions
diff --git a/src/fontfile/bitsource.c b/src/fontfile/bitsource.c
index 3a6a20f..8437d44 100644
--- a/src/fontfile/bitsource.c
+++ b/src/fontfile/bitsource.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
BitmapSourcesRec FontFileBitmapSources;
@@ -49,7 +50,7 @@ FontFileRegisterBitmapSource (FontPathElementPtr fpe)
if (FontFileBitmapSources.count == FontFileBitmapSources.size)
{
newsize = FontFileBitmapSources.size + 4;
- new = realloc (FontFileBitmapSources.fpe, newsize * sizeof *new);
+ new = reallocarray (FontFileBitmapSources.fpe, newsize, sizeof *new);
if (!new)
return FALSE;
FontFileBitmapSources.size = newsize;
diff --git a/src/fontfile/catalogue.c b/src/fontfile/catalogue.c
index 2087232..5df01c2 100644
--- a/src/fontfile/catalogue.c
+++ b/src/fontfile/catalogue.c
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
+#include "src/util/replace.h"
static const char CataloguePrefix[] = "catalogue:";
@@ -64,7 +65,8 @@ CatalogueAddFPE (CataloguePtr cat, FontPathElementPtr fpe)
else
cat->fpeAlloc *= 2;
- new = realloc(cat->fpeList, cat->fpeAlloc * sizeof(FontPathElementPtr));
+ new = reallocarray(cat->fpeList, cat->fpeAlloc,
+ sizeof(FontPathElementPtr));
if (new == NULL)
return AllocError;
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index 2cc97b4..c07222f 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -185,7 +185,7 @@ FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
directory that we should just give up before we overflow. */
return NULL;
newsize = table->size + 100;
- entry = realloc(table->entries, newsize * sizeof(FontEntryRec));
+ entry = reallocarray(table->entries, newsize, sizeof(FontEntryRec));
if (!entry)
return (FontEntryPtr)0;
table->size = newsize;
diff --git a/src/fontfile/fontscale.c b/src/fontfile/fontscale.c
index bbc8e10..7fcaba8 100644
--- a/src/fontfile/fontscale.c
+++ b/src/fontfile/fontscale.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
#include <math.h>
@@ -49,7 +50,7 @@ FontFileAddScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
if (extra->numScaled == extra->sizeScaled)
{
newsize = extra->sizeScaled + 4;
- new = realloc (extra->scaled, newsize * sizeof (FontScaledRec));
+ new = reallocarray (extra->scaled, newsize, sizeof (FontScaledRec));
if (!new)
return FALSE;
extra->sizeScaled = newsize;
diff --git a/src/fontfile/renderers.c b/src/fontfile/renderers.c
index d0c4064..a457fb7 100644
--- a/src/fontfile/renderers.c
+++ b/src/fontfile/renderers.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
static FontRenderersRec renderers;
@@ -80,7 +81,7 @@ FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
}
if(i >= renderers.number) {
- new = realloc (renderers.renderers, sizeof(*new) * (i + 1));
+ new = reallocarray (renderers.renderers, i + 1, sizeof(*new));
if (!new)
return FALSE;
renderers.renderers = new;