diff options
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index a1ad120520..1b21c98a2f 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -133,16 +133,9 @@ char *qstrcpy(char *dst, const char *src) char *qstrncpy(char *dst, const char *src, size_t len) { if (dst && len > 0) { - if (!src) { - *dst = '\0'; - return nullptr; - } -#ifdef Q_CC_MSVC - strncpy_s(dst, len, src, len - 1); -#else - strncpy(dst, src, len); -#endif - dst[len-1] = '\0'; + *dst = '\0'; + if (src) + std::strncat(dst, src, len - 1); } return src ? dst : nullptr; } |