فهرست منبع

Remove arbitrary run line length limit (#4685)

A very strange sequence of copying the run line to a stack char array of
size 300, where it would not even null-terminate the line if it hit the
limit, seems totally unnecessary, since it's dealing with std::strings
in the first place.
This would truncate and pick up garbage from the stack in the stored run
line when length >= 300 characters - causing the test to fail, of course.
Perhaps some of this is an artifact of some older version of the code.

In any case, this change removes the extra copying step and simply uses
the entire std::string result from std::getline() instead.
Tex Riddell 3 سال پیش
والد
کامیت
69e6a84ed1
1فایلهای تغییر یافته به همراه4 افزوده شده و 10 حذف شده
  1. 4 10
      include/dxc/Test/HlslTestUtils.h

+ 4 - 10
include/dxc/Test/HlslTestUtils.h

@@ -216,22 +216,15 @@ inline std::vector<std::string> GetRunLines(const LPCWSTR name) {
 
 
   std::vector<std::string> runlines;
   std::vector<std::string> runlines;
   std::string line;
   std::string line;
-  constexpr size_t runlinesize = 300;
   while (std::getline(infile, line)) {
   while (std::getline(infile, line)) {
     if (!HasRunLine(line))
     if (!HasRunLine(line))
       continue;
       continue;
-    char runline[runlinesize];
-    memset(runline, 0, runlinesize);
-    memcpy(runline, line.c_str(), min(runlinesize, line.size()));
-    runlines.emplace_back(runline);
+    runlines.emplace_back(line);
   }
   }
   return runlines;
   return runlines;
 }
 }
 
 
 inline std::string GetFirstLine(LPCWSTR name) {
 inline std::string GetFirstLine(LPCWSTR name) {
-  char firstLine[300];
-  memset(firstLine, 0, sizeof(firstLine));
-
   const std::wstring path = PathLooksAbsolute(name)
   const std::wstring path = PathLooksAbsolute(name)
                                 ? std::wstring(name)
                                 ? std::wstring(name)
                                 : hlsl_test::GetPathToHlslDataFile(name);
                                 : hlsl_test::GetPathToHlslDataFile(name);
@@ -247,8 +240,9 @@ inline std::string GetFirstLine(LPCWSTR name) {
     VERIFY_FAIL();
     VERIFY_FAIL();
   }
   }
 
 
-  infile.getline(firstLine, _countof(firstLine));
-  return firstLine;
+  std::string line;
+  std::getline(infile, line);
+  return line;
 }
 }
 
 
 inline HANDLE CreateFileForReading(LPCWSTR path) {
 inline HANDLE CreateFileForReading(LPCWSTR path) {