mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
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:
parent
91698770e4
commit
ed4ef31c50
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user