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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user