From 17279d25a90b6d450a5871e9e6418ee69de847e7 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 4 Jul 2022 10:56:46 +0200 Subject: [PATCH] QStringConverter: Do not use std::optional::value() value() can potentially throw an exception. We know that it doesn't in this case, but the compiler doesn't know. And our code checker doesn't know either and generates lots of false positives. Also, without the exception propagation code the resulting binary is probably smaller. Coverity-Id: 386110 Coverity-Id: 384314 Coverity-Id: 383835 Coverity-Id: 383784 Change-Id: Icdacf8e003fd3a6ac8fd260ed335239a59de3295 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira (cherry picked from commit af6b6c8e7cd5ba13a7175db890b21970a1ff82d4) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qstringconverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 38a434f353d..4c94de029ee 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1924,7 +1924,7 @@ QStringConverter::QStringConverter(const char *name, Flags f) { auto e = encodingForName(name); if (e) - iface = encodingInterfaces + int(e.value()); + iface = encodingInterfaces + int(*e); #if QT_CONFIG(icu) else iface = QStringConverterICU::make_icu_converter(&state, name);