From a450694a30e194ede0ede0deee31428d6638690f Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Fri, 6 Dec 2024 17:22:07 +0100 Subject: [PATCH] vtkTesting: fix string allocation `newFileName` is deleted using `delete[]`, so allocate it with `new[]`. --- Testing/Rendering/vtkTesting.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Testing/Rendering/vtkTesting.cxx b/Testing/Rendering/vtkTesting.cxx index 9a7f1791544..e045748e513 100644 --- a/Testing/Rendering/vtkTesting.cxx +++ b/Testing/Rendering/vtkTesting.cxx @@ -908,7 +908,8 @@ int vtkTesting::RegressionTest(vtkAlgorithm* imageSource, double thresh, ostream vtkEmscriptenTestUtilities::PreloadDataFile(hostFileName.c_str(), sandboxedFileName); // so that subsequent code uses the sandboxed file name instead of host file name. delete[] newFileName; - newFileName = strdup(sandboxedFileName.c_str()); + newFileName = new char[sandboxedFileName.size() + 1]; + strcpy(newFileName, sandboxedFileName.c_str()); #endif if (!LookForFile(newFileName)) { @@ -1035,7 +1036,8 @@ int vtkTesting::RegressionTest(vtkAlgorithm* imageSource, double thresh, ostream #ifdef __EMSCRIPTEN__ std::string sandboxedFileName = vtkEmscriptenTestUtilities::PreloadDataFile(newFileName); delete[] newFileName; - newFileName = strdup(sandboxedFileName.c_str()); + newFileName = new char[sandboxedFileName.size() + 1]; + strcpy(newFileName, sandboxedFileName.c_str()); #endif rtPng->SetFileName(newFileName); delete[] newFileName; -- GitLab