summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-06-08 14:02:48 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-08 18:35:48 +0000
commit1f3529d8e8a272be8138eeb4a0d0df7f9717526f (patch)
treeba6439091f60954ebac5655f8f25930f587948a0
parente737c163b0f020045a4f5c4ff7715717afd76096 (diff)
QLocale: use qsnprintf instead of deprecated sprintf
Fixes warnings such as qtbase/src/corelib/text/qlocale_tools.cpp:321:5: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] from AppleClang. Change-Id: Ief10e99abfa0a56c24622ac79db719dde58a4210 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 2e9bc3494f62761660e6ae9b5cc6caa0e170ca9a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/text/qlocale_tools.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp
index 6964550b2d..2419cb4e29 100644
--- a/src/corelib/text/qlocale_tools.cpp
+++ b/src/corelib/text/qlocale_tools.cpp
@@ -318,7 +318,7 @@ double qt_asciiToDouble(const char *num, qsizetype numLen, bool &ok, int &proces
constexpr auto maxDigitsForULongLong = 1 + std::numeric_limits<unsigned long long>::digits10;
// need to ensure that we don't read more than numLen of input:
char fmt[1 + maxDigitsForULongLong + 4 + 1];
- sprintf(fmt, "%s%llu%s", "%", static_cast<unsigned long long>(numLen), "lf%n");
+ qsnprintf(fmt, sizeof fmt, "%s%llu%s", "%", static_cast<unsigned long long>(numLen), "lf%n");
if (qDoubleSscanf(num, QT_CLOCALE, fmt, &d, &processed) < 1)
processed = 0;