Commit 48959f7
committed
QStringConverter: widen nameForEncoding()'s contract
Coverity apparently mixes bootstrap and non-bootstrap builds: it
complains that Encoding::Latin1 indexes encodingInterfaces[]
out-of-range (apparently taking the size of the latter from a
bootstrapped and the value of the former from a non-bootstrap build).
That should somehow be fixed in the Coverity configuration, but it
highlighted the fact that we have a narrow-contract function in this
security-critical class that can trivially have a wide contract, so
widen the contract by returning nullptr for invalid Encoding values.
Consequently, mark the function as noexcept.
As a drive-by, mark it also as Q_DECL_PURE_FUNCTION.
[ChangeLog][QtCore][QStringConverter] The nameForEncoding() function
now returns nullptr for an invalid Encoding value. Before, such a call
resulted in undefined behavior.
Pick-to: 6.9 6.8 6.5
Coverity-Id: 480251
Change-Id: Ie1c5c9df6881147a1ff44fe549e50748b2f5b7da
Reviewed-by: Thiago Macieira <[email protected]>1 parent 0725530 commit 48959f7
File tree
2 files changed
+12
-4
lines changed- src/corelib/text
2 files changed
+12
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2710 | 2710 | | |
2711 | 2711 | | |
2712 | 2712 | | |
2713 | | - | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
2714 | 2719 | | |
2715 | | - | |
| 2720 | + | |
2716 | 2721 | | |
2717 | | - | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
2718 | 2726 | | |
2719 | 2727 | | |
2720 | 2728 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
0 commit comments