mirror of
https://github.com/proxytunnel/proxytunnel.git
synced 2026-01-23 02:34:59 +00:00
Use alloca() instead of malloc()
This make code more readable and spares us some explicit calls to free().
This commit is contained in:
parent
8d69435854
commit
470ac87f73
1 changed files with 1 additions and 8 deletions
|
|
@ -327,10 +327,7 @@ int stream_enable_ssl(PTSTREAM *pts, const char *proxy_arg) {
|
|||
|
||||
/* Determine the host name we are connecting to */
|
||||
proxy_arg_len = strlen(proxy_arg);
|
||||
if ((peer_host = malloc(proxy_arg_len + 1)) == NULL) {
|
||||
message("Out of memory\n");
|
||||
goto fail;
|
||||
}
|
||||
peer_host = alloca(proxy_arg_len + 1);
|
||||
snprintf( proxy_arg_fmt, sizeof(proxy_arg_fmt), proxy_arg[0] == '[' ? "[%%%zu[^]]]" : "%%%zu[^:]", proxy_arg_len - 1 );
|
||||
if ( sscanf( proxy_arg, proxy_arg_fmt, peer_host ) != 1 ) {
|
||||
goto fail;
|
||||
|
|
@ -373,7 +370,6 @@ int stream_enable_ssl(PTSTREAM *pts, const char *proxy_arg) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
free(peer_host);
|
||||
X509_free(cert);
|
||||
}
|
||||
|
||||
|
|
@ -391,9 +387,6 @@ fail:
|
|||
if (cert != NULL) {
|
||||
X509_free(cert);
|
||||
}
|
||||
if (peer_host != NULL) {
|
||||
free(peer_host);
|
||||
}
|
||||
#endif /* USE_SSL */
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue