Commit fb280937 authored by Jean-Paul Saman's avatar Jean-Paul Saman

examples/connect.c: Resource leak (CID 28604)

parent afca8c8e
......@@ -53,7 +53,7 @@ int create_tcp_connection( const char *ipaddress, int port )
if( !ipaddress ) return -1;
s_ctl = socket( PF_INET, SOCK_STREAM, 0 );
if (s_ctl <= 0)
if (s_ctl < 0)
{
perror( "tcp socket error" );
return -1;
......@@ -67,6 +67,7 @@ int create_tcp_connection( const char *ipaddress, int port )
if( result < 0 )
{
perror( "tcp connect error" );
close(s_ctl);
return -1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment