tree-wide: use reallocarray() where appropriate
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Apr 2019 12:50:15 +0000 (14:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Apr 2019 12:54:42 +0000 (14:54 +0200)
src/boot/bootctl.c
src/libsystemd/sd-login/sd-login.c

index 381c234..a7de380 100644 (file)
@@ -675,7 +675,7 @@ static int insert_into_order(uint16_t slot, bool first) {
         }
 
         /* extend array */
-        t = realloc(order, (n + 1) * sizeof(uint16_t));
+        t = reallocarray(order, n + 1, sizeof(uint16_t));
         if (!t)
                 return -ENOMEM;
         order = t;
index 07f21e8..0dc368e 100644 (file)
@@ -818,7 +818,7 @@ _public_ int sd_get_uids(uid_t **users) {
                                 uid_t *t;
 
                                 n = MAX(16, 2*r);
-                                t = realloc(l, sizeof(uid_t) * n);
+                                t = reallocarray(l, sizeof(uid_t), n);
                                 if (!t)
                                         return -ENOMEM;