Skip to content

Commit de6dc46

Browse files
committed
Fix memory leak
1 parent 91cff39 commit de6dc46

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/clients/spdsend/server.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static const char *login_name()
339339
return getpwuid(getuid())->pw_name;
340340
}
341341

342-
static const char *server_socket_name()
342+
static char *server_socket_name()
343343
{
344344
char *name;
345345
if (asprintf(&name, "/tmp/spdsend-server.%s", login_name()) < 0)
@@ -352,7 +352,7 @@ static void serve()
352352
struct sockaddr_un name;
353353
int sock;
354354
size_t size;
355-
const char *filename = server_socket_name();
355+
char *filename = server_socket_name();
356356

357357
sock = socket(PF_LOCAL, SOCK_STREAM, 0);
358358
if (sock < 0)
@@ -367,6 +367,7 @@ static void serve()
367367
system_error("bind");
368368
if (listen(sock, LISTEN_QUEUE_LENGTH) < 0)
369369
system_error("listen");
370+
free(filename);
370371

371372
while (1) {
372373
struct sockaddr_un client_address;

0 commit comments

Comments
 (0)