--- a/win32/win32_compat.c
+++ b/win32/win32_compat.c
@@ -58,7 +58,7 @@
 #else
   char *srcNonConst = (char *)malloc(strLen);
   memset(srcNonConst, 0, strLen);
-  strncpy(srcNonConst, src, strLen);
+  strncpy(srcNonConst, src, sizeof(srcNonConst) - 1);
 #endif
 
   if( WSAStringToAddress(srcNonConst,af,NULL,(LPSOCKADDR)&sa,&len) == 0 )
