summaryrefslogtreecommitdiffstats
path: root/src/core/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-27 19:09:22 +0100
committerLennart Poettering <lennart@poettering.net>2018-03-02 12:39:07 +0100
commit62d74c78b59f95a76778d9fa8dbe3b098afa2aad (patch)
tree138ea4e336b01254a6766e547fdc10c3728255ef /src/core/service.c
parentresolve-tool: use reallocarray() where appropriate (diff)
downloadsystemd-62d74c78b59f95a76778d9fa8dbe3b098afa2aad.tar.xz
systemd-62d74c78b59f95a76778d9fa8dbe3b098afa2aad.zip
coccinelle: add reallocarray() coccinelle script
Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
Diffstat (limited to 'src/core/service.c')
-rw-r--r--src/core/service.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 1997c82ac3..df36019f62 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1254,7 +1254,7 @@ static int service_collect_fds(Service *s,
} else {
int *t;
- t = realloc(rfds, (rn_socket_fds + cn_fds) * sizeof(int));
+ t = reallocarray(rfds, rn_socket_fds + cn_fds, sizeof(int));
if (!t)
return -ENOMEM;
@@ -1276,13 +1276,13 @@ static int service_collect_fds(Service *s,
char **nl;
int *t;
- t = realloc(rfds, (rn_socket_fds + s->n_fd_store) * sizeof(int));
+ t = reallocarray(rfds, rn_socket_fds + s->n_fd_store, sizeof(int));
if (!t)
return -ENOMEM;
rfds = t;
- nl = realloc(rfd_names, (rn_socket_fds + s->n_fd_store + 1) * sizeof(char*));
+ nl = reallocarray(rfd_names, rn_socket_fds + s->n_fd_store + 1, sizeof(char *));
if (!nl)
return -ENOMEM;