diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-02-21 10:59:04 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2023-05-09 19:59:41 +0200 |
commit | 5f9aab1993016720db1d7008ed190b0a96293190 (patch) | |
tree | 4188145a3f54a918ee0e73fdc9e9ac4977f2a6ef | |
parent | 01037c3ebee72192e31e44f5d38baf575832e77d (diff) | |
download | cppunit-5f9aab1993016720db1d7008ed190b0a96293190.tar.gz |
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.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | include/cppunit/TestAssert.h | 2 |
1 files changed, 1 insertions, 1 deletions
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; } |