Part of fix for bug 42458. The Unichar version of nsCRT::strndup wasn't correctly terminating the string. R=varada, SR=mscott

This commit is contained in:
ducarroz%netscape.com 2001-01-08 19:58:12 +00:00
parent 91698770e4
commit ed4ef31c50

View File

@ -512,13 +512,13 @@ PRUnichar* nsCRT::strdup(const PRUnichar* str)
PRUnichar* nsCRT::strndup(const PRUnichar* str, PRUint32 len)
{
len += 1; // add one for the null
nsCppSharedAllocator<PRUnichar> shared_allocator;
PRUnichar* rslt = shared_allocator.allocate(len);
// PRUnichar* rslt = new PRUnichar[len];
PRUnichar* rslt = shared_allocator.allocate(len + 1); // add one for the null
// PRUnichar* rslt = new PRUnichar[len + 1];
if (rslt == NULL) return NULL;
nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar));
rslt[len] = 0;
return rslt;
}