diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2019-08-03 19:29:05 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2019-08-04 11:23:20 -0700 |
commit | ddbee30d3525cdd66b84056affc407601680cc29 (patch) | |
tree | ae251a90a3e4cd3420d361edba93a4ea3656babc /src/bitmap/snfread.c | |
parent | f54470dab5b392380df61a22b4b4bef685b6cee2 (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/bitmap/snfread.c')
-rw-r--r-- | src/bitmap/snfread.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bitmap/snfread.c b/src/bitmap/snfread.c index 452b99d..2e94f9c 100644 --- a/src/bitmap/snfread.c +++ b/src/bitmap/snfread.c @@ -53,6 +53,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <ctype.h> #include <X11/fonts/fntfilst.h> @@ -453,13 +454,13 @@ snfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file) return ret; snfCopyInfo(&fi, pFontInfo); - pFontInfo->props = malloc(fi.nProps * sizeof(FontPropRec)); + pFontInfo->props = mallocarray(fi.nProps, sizeof(FontPropRec)); if (!pFontInfo->props) { snfError("snfReadFontInfo(): Couldn't allocate props (%d*%d)\n", fi.nProps, (int) sizeof(FontPropRec)); return AllocError; } - pFontInfo->isStringProp = malloc(fi.nProps * sizeof(char)); + pFontInfo->isStringProp = mallocarray(fi.nProps, sizeof(char)); if (!pFontInfo->isStringProp) { snfError("snfReadFontInfo(): Couldn't allocate isStringProp (%d*%d)\n", fi.nProps, (int) sizeof(char)); |