[PATCH:libICE 1/2] Free iceConn->connection_string when unwinding after malloc fails

Alan Coopersmith alan.coopersmith at oracle.com
Thu Dec 26 08:53:03 PST 2013


Found by cppcheck 1.62:
[src/accept.c:113]: (error) Memory leak: iceConn.connection_string

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/accept.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/accept.c b/src/accept.c
index 6f23338..610e01b 100644
--- a/src/accept.c
+++ b/src/accept.c
@@ -110,6 +110,7 @@ IceAcceptConnection (
     else
     {
 	_IceTransClose (newconn);
+	free (iceConn->connection_string);
 	free (iceConn);
 	*statusRet = IceAcceptBadMalloc;
 	return (NULL);
@@ -122,6 +123,7 @@ IceAcceptConnection (
     else
     {
 	_IceTransClose (newconn);
+	free (iceConn->connection_string);
 	free (iceConn->inbuf);
 	free (iceConn);
 	*statusRet = IceAcceptBadMalloc;
-- 
1.7.9.2



More information about the xorg-devel mailing list