From ba753120dfc4444beca540f40720687f68422fc1 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Tue, 28 Apr 2015 08:44:13 +0200 Subject: [PATCH] Fix memory leaks --- miniupnpc-async/miniupnpc-async.c | 2 ++ miniupnpc-libevent/miniupnpc-libevent.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/miniupnpc-async/miniupnpc-async.c b/miniupnpc-async/miniupnpc-async.c index c3e70c3..ad16ade 100644 --- a/miniupnpc-async/miniupnpc-async.c +++ b/miniupnpc-async/miniupnpc-async.c @@ -703,6 +703,7 @@ static int upnpc_build_soap_request(upnpc_t * p, const char * url, body = malloc(body_len + 1); if(body == NULL) { p->state = EError; + free(args_xml); return -1; } if(snprintf(body, body_len + 1, fmt_soap, action, service, args_xml?args_xml:"", action) != body_len) { @@ -712,6 +713,7 @@ static int upnpc_build_soap_request(upnpc_t * p, const char * url, args_xml = NULL; if(!parseURL(url, hostname, &port, &path, &scope_id)) { p->state = EError; + free(body); return -1; } if(port != 80) diff --git a/miniupnpc-libevent/miniupnpc-libevent.c b/miniupnpc-libevent/miniupnpc-libevent.c index bb50682..3d1e262 100644 --- a/miniupnpc-libevent/miniupnpc-libevent.c +++ b/miniupnpc-libevent/miniupnpc-libevent.c @@ -614,6 +614,7 @@ static int upnpc_send_soap_request(upnpc_device_t * p, const char * url, body_len = snprintf(NULL, 0, fmt_soap, method, service, args_xml?args_xml:"", method); body = malloc(body_len + 1); if(body == NULL) { + free(args_xml); return -1; } if(snprintf(body, body_len + 1, fmt_soap, method, service, args_xml?args_xml:"", method) != body_len) { @@ -622,6 +623,7 @@ static int upnpc_send_soap_request(upnpc_device_t * p, const char * url, free(args_xml); args_xml = NULL; if(!parseURL(url, hostname, &port, &path, &scope_id)) { + free(body); return -1; } if(port != 80)