diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-04-01 20:13:43 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-04-01 20:13:43 +0200 |
commit | 9adc16fb6f24cc28fa84832675516215cb604a8e (patch) | |
tree | bbbc0f2d429f97a37ff3f6ea21d31a9b991430d9 /FICS/makerank.c | |
parent | c6cd6491f97ae98e9318961a1741326ab45f8ae3 (diff) |
Overflow checking by using reallocarray()
Diffstat (limited to 'FICS/makerank.c')
-rw-r--r-- | FICS/makerank.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/FICS/makerank.c b/FICS/makerank.c index 3e33ac9..a86b0ec 100644 --- a/FICS/makerank.c +++ b/FICS/makerank.c @@ -121,10 +121,10 @@ LoadEntries(void) int listsize; listsize = 100; - list = malloc(sizeof(ENTRY *) * listsize); + list = reallocarray(NULL, sizeof(ENTRY *), listsize); if (list == NULL) - err(1, "%s: malloc", __func__); + err(1, "%s: reallocarray", __func__); for (letter1 = 'a'; letter1 <= 'z'; letter1++) { printf("Loading %c's.\n", letter1); @@ -237,10 +237,11 @@ makerank(void) for (rtype = 0; rtype < 4; rtype++) { sortnum = 0; sortmesize = 100; - sortme = malloc(sizeof(ENTRY *) * sortmesize); + sortme = reallocarray(NULL, sizeof(ENTRY *), + sortmesize); if (sortme == NULL) - err(1, "%s: malloc", __func__); + err(1, "%s: reallocarray", __func__); for (i = 0; i < n; i++) { if (list[i]->r[rtype].rating) { |