include/cppunit/TestAssert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
New commits: commit 5f9aab1993016720db1d7008ed190b0a96293190 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Feb 21 10:59:04 2023 +0100 Commit: Markus Mohrhard <markus.mohrh...@googlemail.com> CommitDate: Tue May 9 19:59:41 2023 +0200 Use snprintf instead of sprintf See <https://git.libreoffice.org/core/+/bd8a213c8ceccf66ab296ef0aea0fa4c451047e5%5E%21> "external/cppunit: Use snprintf instead of sprintf" for how sprintf would have caused deprecation warnings on macOS. (For MSVC, keep using sprintf_s. According to <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=msvc-170>: "Beginning with the UCRT in Visual Studio 2015 and Windows 10, snprintf is no longer identical to _snprintf. The snprintf function behavior is now C99 standard conformant." So for older versions, snprintf would potentially not store a terminating NUL, like _snprintf but unlike sprintf_s.) Change-Id: Ibf8b228cd1dd57428ecf85ed10e0793b78ae90c9 Reviewed-on: https://gerrit.libreoffice.org/c/cppunit/+/147383 Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h index 521a4e4..19a8ae5 100644 --- a/include/cppunit/TestAssert.h +++ b/include/cppunit/TestAssert.h @@ -112,7 +112,7 @@ struct assertion_traits<double> #ifdef __STDC_SECURE_LIB__ // Use secure version with visual studio 2005 to avoid warning. sprintf_s(buffer, sizeof(buffer), "%.*g", precision, x); #else - sprintf(buffer, "%.*g", precision, x); + snprintf(buffer, sizeof(buffer), "%.*g", precision, x); #endif return buffer; }