The initial logic for allocating the new string was wrong, the conversion

to strndup(3) duplicated the same mistake, actually strdup(3) is good enough
to allocate the new string.
This commit is contained in:
Baptiste Daroussin 2015-05-10 10:15:36 +00:00
parent a84caa72b0
commit 36dc2e6885

View File

@ -213,15 +213,12 @@ char *
newstr(char const * p)
{
char *q;
size_t l;
if ((p = unquote(p)) == NULL)
return (NULL);
l = strlen(p) + 1;
if ((q = strndup(p, l)) == NULL)
err(1, "strndup()");
if ((q = strdup(p)) == NULL)
err(1, "strdup()");
return (q);
}