summaryrefslogtreecommitdiff
path: root/src/or/ntmain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/ntmain.c')
-rw-r--r--src/or/ntmain.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/or/ntmain.c b/src/or/ntmain.c
index 8d03ea8087..da19573a46 100644
--- a/src/or/ntmain.c
+++ b/src/or/ntmain.c
@@ -456,9 +456,9 @@ nt_service_command_line(int *using_default_torrc)
{
TCHAR tor_exe[MAX_PATH+1];
char tor_exe_ascii[MAX_PATH+1];
- char *command, *options=NULL;
+ char *command=NULL, *options=NULL;
smartlist_t *sl;
- int i, cmdlen;
+ int i;
*using_default_torrc = 1;
/* Get the location of tor.exe */
@@ -487,21 +487,13 @@ nt_service_command_line(int *using_default_torrc)
strlcpy(tor_exe_ascii, tor_exe, sizeof(tor_exe_ascii));
#endif
- /* Allocate a string for the NT service command line */
- cmdlen = strlen(tor_exe_ascii) + (options?strlen(options):0) + 32;
- command = tor_malloc(cmdlen);
-
+ /* Allocate a string for the NT service command line and */
/* Format the service command */
if (options) {
- if (tor_snprintf(command, cmdlen, "\"%s\" --nt-service \"%s\"",
- tor_exe_ascii, options)<0) {
- tor_free(command); /* sets command to NULL. */
- }
+ tor_asprintf(&command, "\"%s\" --nt-service \"%s\"",
+ tor_exe_ascii, options);
} else { /* ! options */
- if (tor_snprintf(command, cmdlen, "\"%s\" --nt-service",
- tor_exe_ascii)<0) {
- tor_free(command); /* sets command to NULL. */
- }
+ tor_asprintf(&command, "\"%s\" --nt-service", tor_exe_ascii);
}
tor_free(options);