Use *array() allocation functions where appropriate

This prevents overflow from multiplication.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-02-04 21:47:01 +01:00
committed by Serge Hallyn
parent 727275a027
commit 191f04f7dc
18 changed files with 26 additions and 26 deletions
+4 -4
View File
@@ -44,7 +44,7 @@
* old entries, and the new entries as well.
*/
tmp = (char **) xmalloc ((i + 2) * sizeof member);
tmp = (char **) xmallocarray (i + 2, sizeof member);
/*
* Copy the original list to the new list, then append the
@@ -98,7 +98,7 @@
* old entries.
*/
tmp = (char **) xmalloc ((j + 1) * sizeof member);
tmp = (char **) xmallocarray (j + 1, sizeof member);
/*
* Copy the original list except the deleted members to the
@@ -133,7 +133,7 @@
for (i = 0; NULL != list[i]; i++);
tmp = (char **) xmalloc ((i + 1) * sizeof (char *));
tmp = (char **) xmallocarray (i + 1, sizeof (char *));
i = 0;
while (NULL != *list) {
@@ -210,7 +210,7 @@ bool is_on_list (char *const *list, const char *member)
* Allocate the array we're going to store the pointers into.
*/
array = (char **) xmalloc (sizeof (char *) * i);
array = (char **) xmallocarray (i, sizeof (char *));
/*
* Empty list is special - 0 members, not 1 empty member. --marekm