dermesser / libsocket

The ultimate socket library for C and C++, supporting TCP, UDP and Unix sockets (DGRAM and STREAM) on Linux, FreeBSD, Solaris. See also my uvco library for a refreshed version!
https://borgac.net/~lbo/doc/libsocket/
Other
802 stars 195 forks source link

memory leakage in create_unix_stream_socket #56

Closed darktrial closed 6 years ago

darktrial commented 6 years ago

After check the connection status in below code, the sfd variable needs to be freed. if ( -1 == check_error(connect(sfd,(struct sockaddr*)&saddr,sizeof(saddr.sun_family) + strlen(saddr.sun_path)) ) ) return -1;

The code should be changed as below.

if ( -1 == check_error(connect(sfd,(struct sockaddr*)&saddr,sizeof(saddr.sun_family) + strlen(saddr.sun_path)) ) ) { close(sfd); return -1; }

dermesser commented 6 years ago

Thank you for the report!