From 7479c855a0362927055bc69ba14ccda90bc1de48 Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Tue, 24 Aug 2010 00:04:51 -0400 Subject: [PATCH] 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. --- lib/roken/strlcpy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/roken/strlcpy.c b/lib/roken/strlcpy.c index 7c1789bd1..0fe2b97fc 100644 --- a/lib/roken/strlcpy.c +++ b/lib/roken/strlcpy.c @@ -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); }