[libdvbpsi-devel] examples/connect.c: Resource leak (CID 28605)

Jean-Paul Saman git at videolan.org
Wed Apr 16 15:53:38 CEST 2014


libdvbpsi | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Wed Apr 16 11:32:58 2014 +0200| [1f9cf2f251ed0ed9f4f135425934fa0a4938774c] | committer: Jean-Paul Saman

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

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=1f9cf2f251ed0ed9f4f135425934fa0a4938774c
---

 examples/connect.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/examples/connect.c b/examples/connect.c
index cb03a26..fa53902 100644
--- a/examples/connect.c
+++ b/examples/connect.c
@@ -93,7 +93,7 @@ int create_udp_connection( const char *ipaddress, int port )
     if( !ipaddress ) return -1;
 
     s_ctl = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-    if (s_ctl <= 0)
+    if (s_ctl < 0)
     {
         perror( "udp socket error" );
         return -1;
@@ -106,6 +106,7 @@ int create_udp_connection( const char *ipaddress, int port )
     result = bind(s_ctl, (struct sockaddr*) &addr_ctl, sizeof(addr_ctl));
     if( result < 0 )
     {
+        close(s_ctl);
         perror( "udp bind error" );
         return -1;
     }



More information about the libdvbpsi-devel mailing list