diff options
-rw-r--r-- | src/m_misc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/m_misc.c b/src/m_misc.c index 2e363412..ab3c7009 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -372,12 +372,15 @@ char *M_StringReplace(const char *haystack, const char *needle, boolean M_StringCopy(char *dest, const char *src, size_t dest_size) { + size_t len; + if (dest_size >= 1) { dest[dest_size - 1] = '\0'; strncpy(dest, src, dest_size - 1); } - return strlen(dest) == strlen(src); + len = strlen(dest); + return src[len] == '\0'; } // Safe string concat function that works like OpenBSD's strlcat(). |