Skip to content

Commit 79bf66e

Browse files
committed
Solved memory leak issues
1 parent 1b63785 commit 79bf66e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

proxy-helpers/url_parser.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ URL_INFO *parse_url(URL_INFO *info, const char *url)
3333
init_url_info(info);
3434

3535
char *url_copy = (char *)Malloc(strlen(url) + 1);
36-
char *temp = url_copy;
36+
char *temp_host = (char *)Malloc(strlen(url) + 1);
37+
char *temp_host_ptr = temp_host;
3738
strcpy(url_copy, url);
3839
strcpy(info->protocol, __strtok_r(url_copy, "://", &save_ptr));
39-
strcpy(url_copy, strstr(url, "://"));
40+
strcpy(temp_host, strstr(url, "://"));
4041

41-
if (url_copy) {
42-
url_copy += 3;
43-
strcpy(info->host, url_copy);
42+
if (temp_host) {
43+
temp_host += 3;
44+
strcpy(info->host, temp_host);
4445
char *host_port_path = (char *)Calloc(1, strlen(info->host) + 1);
4546
strcpy(host_port_path, info->host);
4647
strcpy(info->host, __strtok_r(host_port_path, ":", &save_ptr));
@@ -82,7 +83,8 @@ URL_INFO *parse_url(URL_INFO *info, const char *url)
8283
else if (r)
8384
strcpy(info->protocol, "tcp");
8485

85-
Free(temp);
86+
Free(url_copy);
87+
Free(temp_host_ptr);
8688
Free(URL);
8789
Free(port_path_copy);
8890
return info;

0 commit comments

Comments
 (0)