- die if malloc fails.

- use strlcpy.

Obtained from:	KAME
MFC after:	1 week
This commit is contained in:
Hajimu UMEMOTO 2003-08-17 16:07:57 +00:00
parent be71e4ad8a
commit 1dd7cfc46f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119033

View File

@ -3261,9 +3261,15 @@ char *
allocopy(p)
char *p;
{
char *q = (char *)malloc(strlen(p) + 1);
int len = strlen(p) + 1;
char *q = (char *)malloc(len);
strcpy(q, p);
if (!q) {
fatal("malloc");
/*NOTREACHED*/
}
strlcpy(q, p, len);
return q;
}