Skip to content

Commit 9f2aa42

Browse files
committed
memory leak
1 parent 63f1210 commit 9f2aa42

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cli/cliMsg.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ OBJ BgnMsgsend(const char *hostname, int channel)
5757
int sockfd;
5858
desc *o = (desc *)malloc(sizeof(desc));
5959
if (!o)
60-
return (OBJ)0;
60+
return NULL;
6161

6262
#ifdef VSS_WINDOWS_OLDWAY
6363
{
@@ -92,16 +92,18 @@ OBJ BgnMsgsend(const char *hostname, int channel)
9292
o->addr.sin_port = htons(channel);
9393
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
9494
printf("Failed to make socket.\n");
95-
return (OBJ)0;
95+
free(o);
96+
return NULL;
9697
}
9798
memset((char *)&cl_addr, 0, sizeof(cl_addr));
9899
cl_addr.sin_family = AF_INET;
99100
cl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
100101
cl_addr.sin_port = htons(0);
101102
if (bind(sockfd, (struct sockaddr *)&cl_addr, sizeof(cl_addr)) < 0) {
102-
close(sockfd);
103103
perror("failed to bind socket");
104-
return (OBJ)0;
104+
close(sockfd);
105+
free(o);
106+
return NULL;
105107
}
106108

107109
fcntl(sockfd, F_SETFL, FNDELAY); // Non-blocking I/O

0 commit comments

Comments
 (0)