- snprintf(destination, size, "%s", source);
- /*
- * Platforms that lack strlcpy() also tend to have
- * a broken snprintf implementation that doesn't
- * guarantee nul termination.
- *
- * XXX: the configure script should detect and reject those.
- */
- destination[(size > 1) ? size-1 : 0] = '\0';
-
+ if (0 < size)
+ {
+ snprintf(destination, size, "%s", source);
+ /*
+ * Platforms that lack strlcpy() also tend to have
+ * a broken snprintf implementation that doesn't
+ * guarantee nul termination.
+ *
+ * XXX: the configure script should detect and reject those.
+ */
+ destination[size-1] = '\0';
+ }