浏览代码

cmCommandArgumentParserHelper: Avoid -Wstringop-truncation warning

Use `memcpy` instead of `strncpy` to copy bytes from a buffer that
may not be null terminated.
Brad King 7 年之前
父节点
当前提交
9df0e1f98a
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Source/cmCommandArgumentParserHelper.cxx

+ 1 - 1
Source/cmCommandArgumentParserHelper.cxx

@@ -172,7 +172,7 @@ void cmCommandArgumentParserHelper::AllocateParserType(
     return;
   }
   char* out = new char[len + 1];
-  strncpy(out, str, len);
+  memcpy(out, str, len);
   out[len] = 0;
   pt->str = out;
   this->Variables.push_back(out);