summaryrefslogtreecommitdiff
path: root/fslsfonts.c
diff options
context:
space:
mode:
Diffstat (limited to 'fslsfonts.c')
-rw-r--r--fslsfonts.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fslsfonts.c b/fslsfonts.c
index 3608e5a..ce8f7ab 100644
--- a/fslsfonts.c
+++ b/fslsfonts.c
@@ -53,6 +53,14 @@ in this Software without prior written authorization from The Open Group.
#include <stdlib.h>
#include <assert.h>
+#ifdef HAVE_BSD_STDLIB_H
+#include <bsd/stdlib.h>
+#endif
+
+#ifndef HAVE_REALLOCARRAY
+#define reallocarray(old, num, size) realloc(old, (num) * (size))
+#endif
+
#ifndef N_START
#define N_START 1000 /* Maximum # of fonts to start with */
#endif
@@ -267,8 +275,8 @@ get_list(const char *pattern)
else {
FontList *old_list = font_list;
- font_list = realloc(old_list, (font_cnt + (unsigned) available)
- * sizeof(FontList));
+ font_list = reallocarray(old_list, (font_cnt + (unsigned) available),
+ sizeof(FontList));
if (font_list == NULL) {
free(old_list);