summaryrefslogtreecommitdiffstats
path: root/lib/route
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2017-06-08 08:59:28 (GMT)
committerRasmus Villemoes <linux@rasmusvillemoes.dk>2017-06-08 08:59:28 (GMT)
commit76464f641e7effb3383150ad8056688858a53b49 (patch)
tree2417a56913a3bbac822be5cb8923c55e611c78f6 /lib/route
parenta7f73d0e7b3bfc19bcf5a31ff33feeaec141e2ac (diff)
downloadlibnl-76464f641e7effb3383150ad8056688858a53b49.zip
libnl-76464f641e7effb3383150ad8056688858a53b49.tar.gz
libnl-76464f641e7effb3383150ad8056688858a53b49.tar.bz2
lib/route/qdisc/netem.c: avoid memory leak if realloc fails
PS: There's some serious whitespace damage in this vicinity (starting around line 269), making one wonder if the ifs and elses are matched as they should be.
Diffstat (limited to 'lib/route')
-rw-r--r--lib/route/qdisc/netem.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c
index 8ecc405..fd023fc 100644
--- a/lib/route/qdisc/netem.c
+++ b/lib/route/qdisc/netem.c
@@ -274,10 +274,11 @@ static int netem_msg_fill_raw(struct rtnl_tc *tc, void *data,
/* Resize to accomodate the large distribution table */
int new_msg_len = msg->nm_size + netem->qnm_dist.dist_size *
sizeof(netem->qnm_dist.dist_data[0]);
+ struct nlmsghdr *new_nlh = realloc(msg->nm_nlh, new_msg_len);
- msg->nm_nlh = (struct nlmsghdr *) realloc(msg->nm_nlh, new_msg_len);
- if ( msg->nm_nlh == NULL )
+ if ( new_nlh == NULL )
return -NLE_NOMEM;
+ msg->nm_nlh = new_nlh;
msg->nm_size = new_msg_len;
set_dist = 1;
}