mirror of
https://git.savannah.gnu.org/git/inetutils.git
synced 2026-01-12 00:19:39 +08:00
telnet/commands.c: Use strdup instead malloc+strcpy
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user