coccinelle: add reallocarray() coccinelle script

Let's systematically make use of reallocarray() whereever we invoke
realloc() with a product of two values.
This commit is contained in:
Lennart Poettering
2018-03-02 12:39:07 +01:00
parent 3209c8e650
commit 62d74c78b5
16 changed files with 56 additions and 37 deletions
+1 -1
View File
@@ -1400,7 +1400,7 @@ static int message_push_fd(sd_bus_message *m, int fd) {
if (copy < 0)
return -errno;
f = realloc(m->fds, sizeof(int) * (m->n_fds + 1));
f = reallocarray(m->fds, sizeof(int), m->n_fds + 1);
if (!f) {
m->poisoned = true;
safe_close(copy);
+1 -1
View File
@@ -1223,7 +1223,7 @@ int bus_socket_read_message(sd_bus *bus) {
return -EIO;
}
f = realloc(bus->fds, sizeof(int) * (bus->n_fds + n));
f = reallocarray(bus->fds, bus->n_fds + n, sizeof(int));
if (!f) {
close_many((int*) CMSG_DATA(cmsg), n);
return -ENOMEM;