diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2019-08-03 19:09:19 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2019-08-03 19:31:14 -0700 |
commit | f54470dab5b392380df61a22b4b4bef685b6cee2 (patch) | |
tree | 561d2a367f295f3fe53f72712b3b3f3d1011ec18 /src/util | |
parent | 27207d35d4b4bbd5d2b2c5f7e13a61ea43d04a4a (diff) | |
download | xorg-lib-libXfont-f54470dab5b392380df61a22b4b4bef685b6cee2.tar.gz |
Convert multiplying realloc calls to use reallocarray instead
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/fontnames.c | 5 | ||||
-rw-r--r-- | src/util/fontutil.c | 5 | ||||
-rw-r--r-- | src/util/private.c | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/util/fontnames.c b/src/util/fontnames.c index b292480..4460728 100644 --- a/src/util/fontnames.c +++ b/src/util/fontnames.c @@ -35,6 +35,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fontmisc.h> #include <X11/fonts/fontstruct.h> @@ -100,8 +101,8 @@ xfont2_add_font_names_name(FontNamesPtr names, if (size == 0) size = 8; - nlength = realloc(names->length, size * sizeof(int)); - nnames = realloc(names->names, size * sizeof(char *)); + nlength = reallocarray(names->length, size, sizeof(int)); + nnames = reallocarray(names->names, size, sizeof(char *)); if (nlength && nnames) { names->size = size; names->length = nlength; diff --git a/src/util/fontutil.c b/src/util/fontutil.c index d1b845b..f7ac507 100644 --- a/src/util/fontutil.c +++ b/src/util/fontutil.c @@ -34,6 +34,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fontmisc.h> #include <X11/fonts/fontstruct.h> #include <X11/fonts/FSproto.h> @@ -307,8 +308,8 @@ add_range(fsRange *newrange, } else if (!(*nranges % range_alloc_granularity)) { - *range = realloc(*range, (*nranges + range_alloc_granularity) * - SIZEOF(fsRange)); + *range = reallocarray(*range, (*nranges + range_alloc_granularity), + SIZEOF(fsRange)); } /* If alloc failed, just return a null list */ diff --git a/src/util/private.c b/src/util/private.c index 92075c2..47c2699 100644 --- a/src/util/private.c +++ b/src/util/private.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/fontmisc.h> #include <X11/fonts/fontstruct.h> @@ -84,7 +85,7 @@ xfont2_font_set_private(FontPtr pFont, int n, pointer ptr) if (n > pFont->maxPrivate) { if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) { - new = realloc (pFont->devPrivates, (n + 1) * sizeof (pointer)); + new = reallocarray (pFont->devPrivates, (n + 1), sizeof (pointer)); if (!new) return FALSE; } else { |