From bda5cb765dd7b1aabf7c7b8d3945d3ead2ed42ad Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 2 Jun 2017 17:48:28 +0200 Subject: ratp: avoid using already freed memory If ratp_establish() fails we would be accessing the ratp_internal struct after having disposed it. Signed-off-by: Aleksander Morgado Signed-off-by: Sascha Hauer --- lib/ratp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ratp.c b/lib/ratp.c index d596a0e8b2..22e83636fd 100644 --- a/lib/ratp.c +++ b/lib/ratp.c @@ -1658,6 +1658,8 @@ int ratp_establish(struct ratp *ratp, bool active, int timeout_ms) } out: + ri->in_ratp--; + if (ret) { free(ri->recvbuf); free(ri->sendbuf); @@ -1665,8 +1667,6 @@ out: ratp->internal = NULL; } - ri->in_ratp--; - return ret; } -- cgit v1.2.3