Skip to content

Commit 21c569a

Browse files
committed
fix incorrect size of malloc
1 parent 1186830 commit 21c569a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

mocks/TCPSocketStub.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,22 @@ void set_test_response(const char *buffer) {
7373
response_buffer_bytes_sent = 0;
7474
}
7575

76-
const char * test_ip(void) {
77-
return "1.2.3.4";
78-
}
79-
8076
void test_init(void) {
8177
int inet_pton_result;
8278

8379
inet_ips = malloc(32);
8480
last_request = malloc(last_request_size + 1);
8581
memset(last_request, 0, last_request_size + 1);
8682

87-
inet_pton_result = inet_pton(AF_INET, test_ip(), inet_ips);
83+
inet_pton_result = inet_pton(AF_INET, "1.2.3.4", inet_ips);
8884
if (inet_pton_result == 0) {
89-
printf("Invalid IP for testing: %s\n", test_ip());
85+
printf("Invalid IP for testing: %s\n", "1.2.3.4");
9086
exit(1);
9187
} else if (inet_pton_result == -1) {
9288
perror("Invalid address class");
9389
exit(1);
9490
}
95-
hent = (struct hostent *)malloc(sizeof(struct hostent *));
91+
hent = (struct hostent *)malloc(sizeof(struct hostent));
9692

9793
response_buffer = malloc(response_buffer_size + 1);
9894
memset(response_buffer, 0, response_buffer_size + 1);

0 commit comments

Comments
 (0)