summaryrefslogtreecommitdiff
path: root/src/fc
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2019-08-03 19:29:05 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2019-08-04 11:23:20 -0700
commitddbee30d3525cdd66b84056affc407601680cc29 (patch)
treeae251a90a3e4cd3420d361edba93a4ea3656babc /src/fc
parentf54470dab5b392380df61a22b4b4bef685b6cee2 (diff)
Convert multiplying malloc calls to use mallocarray instead
Introduces mallocarray as a macro calling reallocarray with a NULL pointer for the old allocation. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/fc')
-rw-r--r--src/fc/fsconvert.c3
-rw-r--r--src/fc/fserve.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/fc/fsconvert.c b/src/fc/fsconvert.c
index 312bacb..34230e9 100644
--- a/src/fc/fsconvert.c
+++ b/src/fc/fsconvert.c
@@ -29,6 +29,7 @@
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/X.h>
#include <X11/Xtrans/Xtrans.h>
#include <X11/Xpoll.h>
@@ -107,7 +108,7 @@ _fs_convert_props(fsPropInfo *pi, fsPropOffset *po, pointer pd,
|| nprops > SIZE_MAX/(sizeof(FontPropRec) + sizeof(char)))
return -1;
- dprop = malloc(sizeof(FontPropRec) * nprops + sizeof (char) * nprops);
+ dprop = mallocarray(nprops, sizeof(FontPropRec) + sizeof (char));
if (!dprop)
return -1;
diff --git a/src/fc/fserve.c b/src/fc/fserve.c
index 46f100e..824b355 100644
--- a/src/fc/fserve.c
+++ b/src/fc/fserve.c
@@ -1089,7 +1089,7 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
pCI = NULL;
}
else
- pCI = malloc(sizeof(CharInfoRec) * numInfos);
+ pCI = mallocarray(numInfos, sizeof(CharInfoRec));
if (!pCI)
{