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/bitscale.c | |
parent | f54470dab5b392380df61a22b4b4bef685b6cee2 (diff) | |
download | xorg-lib-libXfont-ddbee30d3525cdd66b84056affc407601680cc29.tar.gz |
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/bitscale.c')
-rw-r--r-- | src/bitmap/bitscale.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c index 5f77635..12d40d1 100644 --- a/src/bitmap/bitscale.c +++ b/src/bitmap/bitscale.c @@ -34,6 +34,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fntfilst.h> #include <X11/fonts/bitmap.h> @@ -585,7 +586,7 @@ ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */ } nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) + sizeof(rawFontPropTable) / sizeof(fontProp); - fp = malloc(sizeof(FontPropRec) * nProps); + fp = mallocarray(sizeof(FontPropRec), nProps); *pProps = fp; if (!fp) { fprintf(stderr, "Error: Couldn't allocate font properties (%ld*%d)\n", @@ -859,7 +860,7 @@ ScaleFont(FontPtr opf, /* originating font */ bitmapFont->encoding = 0; bitmapFont->bitmapExtra = 0; bitmapFont->pDefault = 0; - bitmapFont->metrics = malloc(nchars * sizeof(CharInfoRec)); + bitmapFont->metrics = mallocarray(nchars, sizeof(CharInfoRec)); if (!bitmapFont->metrics) { fprintf(stderr, "Error: Couldn't allocate metrics (%d*%ld)\n", nchars, (unsigned long)sizeof(CharInfoRec)); @@ -1174,7 +1175,7 @@ ScaleBitmap(FontPtr pFont, CharInfoPtr opci, CharInfoPtr pci, /* Looks like we need to anti-alias. Create a workspace to contain the grayscale character plus an additional row and column for scratch */ - char_grayscale = malloc((width + 1) * (height + 1)); + char_grayscale = mallocarray((width + 1), (height + 1)); if (char_grayscale) { diffusion_workspace = calloc((newWidth + 2) * 2, sizeof(int)); |