- 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

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;
}