From 96ce0e7bc5ff6ced72f6ba072ac592024d3e9f81 Mon Sep 17 00:00:00 2001 From: Conrad Poelman Date: Tue, 5 Oct 2021 15:50:36 -0400 Subject: [PATCH] NULL->string() to eliminate UB, support MSVC 2022 Per https://www.cplusplus.com/reference/string/string/string: "If s is a null pointer ... it causes undefined behavior." This article by C++ Standards Committee member Aaron Ballman reinforces that: https://wiki.sei.cmu.edu/confluence/display/cplusplus/STR51-CPP.+Do+not+attempt+to+create+a+std%3A%3Astring+from+a+null+pointer The MSVC 2022 Preview release, with /std:c++latest, flags this lines as an error. --- src/Utilities/StringTokenizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities/StringTokenizer.cpp b/src/Utilities/StringTokenizer.cpp index 6a37b50..d50ace3 100644 --- a/src/Utilities/StringTokenizer.cpp +++ b/src/Utilities/StringTokenizer.cpp @@ -221,7 +221,7 @@ namespace ColPack if (TokenStringLength == 0) { - return(NULL); + return string(); } if (DelimiterStringLength == 0)