ImStrncpy: Fixed -Wstringop-truncation warning on GCC8 (#2323)

This commit is contained in:
Francisco Gallego 2019-01-30 10:19:40 +01:00 committed by omar
parent ed240c910b
commit aacf993ee1

View File

@ -1295,7 +1295,8 @@ int ImStrnicmp(const char* str1, const char* str2, size_t count)
void ImStrncpy(char* dst, const char* src, size_t count) void ImStrncpy(char* dst, const char* src, size_t count)
{ {
if (count < 1) return; if (count < 1) return;
strncpy(dst, src, count); if (count > 1)
strncpy(dst, src, count-1);
dst[count-1] = 0; dst[count-1] = 0;
} }