diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-27 19:09:22 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-03-02 12:39:07 +0100 |
commit | 62d74c78b59f95a76778d9fa8dbe3b098afa2aad (patch) | |
tree | 138ea4e336b01254a6766e547fdc10c3728255ef /src/libsystemd-network | |
parent | resolve-tool: use reallocarray() where appropriate (diff) | |
download | systemd-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/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/network-internal.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 94386e4860..584a1f36ac 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -424,7 +424,7 @@ int deserialize_in_addrs(struct in_addr **ret, const char *string) { if (r == 0) break; - new_addresses = realloc(addresses, (size + 1) * sizeof(struct in_addr)); + new_addresses = reallocarray(addresses, size + 1, sizeof(struct in_addr)); if (!new_addresses) return -ENOMEM; else @@ -478,7 +478,7 @@ int deserialize_in6_addrs(struct in6_addr **ret, const char *string) { if (r == 0) break; - new_addresses = realloc(addresses, (size + 1) * sizeof(struct in6_addr)); + new_addresses = reallocarray(addresses, size + 1, sizeof(struct in6_addr)); if (!new_addresses) return -ENOMEM; else |