upnpsoap.c: fix 2 memory leaks in GetListOfPortMappings()

This commit is contained in:
Thomas Bernard 2013-02-06 15:03:25 +01:00
parent 49f38310fa
commit dce91afe3c
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.322 2013/01/29 21:52:44 nanard Exp $ $Id: Changelog.txt,v 1.325 2013/02/06 13:14:50 nanard Exp $
2013/02/06:
fix 2 potential memory leaks in GetListOfPortMappings()
2013/01/29: 2013/01/29:
upnphttp.c: Fix and comment the findendheaders() function upnphttp.c: Fix and comment the findendheaders() function

View File

@ -1,4 +1,4 @@
/* $Id: upnpsoap.c,v 1.113 2012/10/04 22:10:26 nanard Exp $ */ /* $Id: upnpsoap.c,v 1.114 2013/02/06 12:40:25 nanard Exp $ */
/* MiniUPnP project /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2012 Thomas Bernard * (c) 2006-2012 Thomas Bernard
@ -952,6 +952,7 @@ http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd">
if(bodylen < 0) if(bodylen < 0)
{ {
SoapError(h, 501, "ActionFailed"); SoapError(h, 501, "ActionFailed");
free(body);
return; return;
} }
memcpy(body+bodylen, list_start, sizeof(list_start)); memcpy(body+bodylen, list_start, sizeof(list_start));
@ -965,12 +966,14 @@ http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd">
/* have a margin of 1024 bytes to store the new entry */ /* have a margin of 1024 bytes to store the new entry */
if((unsigned int)bodylen + 1024 > bodyalloc) if((unsigned int)bodylen + 1024 > bodyalloc)
{ {
char * body_sav = body;
bodyalloc += 4096; bodyalloc += 4096;
body = realloc(body, bodyalloc); body = realloc(body, bodyalloc);
if(!body) if(!body)
{ {
ClearNameValueList(&data); ClearNameValueList(&data);
SoapError(h, 501, "ActionFailed"); SoapError(h, 501, "ActionFailed");
free(body_sav);
free(port_list); free(port_list);
return; return;
} }