summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 14:06:35 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 14:06:35 -0500
commitb4e3d5e14cd5d33d808605892e471bb65640ae76 (patch)
tree0e910b80d9d3952c19c704926ffb38c84b4f52f0
parent2c07315225bef6be4830bce25a74da7f0ba4fcdc (diff)
networkctl: avoid leak if a field was specified twice
The input data would have to be borked, so this is unlikely to happen, but since we have a nice helper function to do it properly... why not? CID #1261390.
-rw-r--r--src/network/networkctl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 063751376a..3a6faa273d 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -965,14 +965,14 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
continue;
if (streq(a, "_Chassis")) {
- chassis = strdup(b);
- if (!chassis)
- return -ENOMEM;
+ r = free_and_strdup(&chassis, b);
+ if (r < 0)
+ return r;
} else if (streq(a, "_Port")) {
- port = strdup(b);
- if (!port)
- return -ENOMEM;
+ r = free_and_strdup(&port, b);
+ if (r < 0)
+ return r;
} else if (streq(a, "_TTL")) {
long long unsigned x;