소스 검색

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

Francisco Gallego 6 년 전
부모
커밋
aacf993ee1
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      imgui.cpp

+ 2 - 1
imgui.cpp

@@ -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;
 }
 }