telnet/commands.c: Use strdup instead malloc+strcpy

This commit is contained in:
Tim Rühsen
2020-02-29 19:42:00 +01:00
parent 22243e6f8e
commit 908bfc85ed

View File

@@ -2583,10 +2583,8 @@ tn (int argc, char *argv[])
}
free (hostname);
hostname = malloc (strlen (hostp) + 1);
if (hostname)
strcpy (hostname, hostp);
else
hostname = strdup (hostp);
if (!hostname)
{
printf ("Can't allocate memory to copy hostname\n");
return 0;