浏览代码

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)
 {
     if (count < 1) return;
-    strncpy(dst, src, count);
+    if (count > 1)
+      strncpy(dst, src, count-1);
     dst[count-1] = 0;
 }