-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
2 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ static const char | |
"PartOf=sslh@%s.socket\n"; | ||
|
||
static char *resolve_listen(const char *hostname, const char *port) { | ||
char *conn = malloc(strlen(hostname) + strlen(port) + 2); | ||
char *conn = calloc(1, strlen(hostname) + strlen(port) + 2); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yrutschle
Author
Owner
|
||
CHECK_ALLOC(conn, "malloc") | ||
strcpy(conn, hostname); | ||
strcat(conn, ":"); | ||
|
@@ -86,12 +86,7 @@ static int get_listen_from_conf(const char *filename, char **listen[]) { | |
config_setting_source_line(addr)); | ||
return -1; | ||
} else { | ||
char *resolved_listen = resolve_listen(hostname, port); | ||
|
||
(*listen)[i] = malloc(strlen(resolved_listen)); | ||
CHECK_ALLOC((*listen)[i], "malloc"); | ||
strcpy((*listen)[i], resolved_listen); | ||
free(resolved_listen); | ||
(*listen)[i] = resolve_listen(hostname, port); | ||
} | ||
} | ||
} | ||
|
The calloc is used for arrays, but here the malloc was more appropriare.