Windows: Don't attempt to copy a string to a zero length buffer

It won't cause harm since strcpy_s() deals with zero length buffers,
but it invokes the invalid parameter handler, which can disrupt
execution on debug builds.
This commit is contained in:
Asanka Herath
2010-08-24 00:04:51 -04:00
committed by Asanka C. Herath
parent d4fc674024
commit 7479c855a0

View File

@@ -43,7 +43,8 @@ strlcpy (char *dst, const char *src, size_t dst_cch)
{
errno_t e;
e = strcpy_s(dst, dst_cch, src);
if (dst_cch > 0)
e = strncpy_s(dst, dst_cch, src, _TRUNCATE);
return strlen (src);
}