Qt: Fix segfault when some ICU codec is not available

$ gdb --args wireshark
    (gdb) run
    Starting program: /usr/bin/wireshark
    [New LWP 10363]
    [New LWP 10364]
     ** (wireshark:10356) 13:13:14.137941 [GUI WARNING] -- codecForName: ucnv_open failed ISO-8859-2 U_FILE_ACCESS_ERROR
    (gdb) bt
    Thread 1 "wireshark" received signal SIGSEGV, Segmentation fault.
    0x00005555557b1959 in MainWindow::findTextCodecs (this=0x7fffecdfd390) at wireshark-3.6.5/ui/qt/main_window.cpp:2029
    2029            QString key = codec->name().toUpper();
    (gdb) bt
    #0  0x00005555557b1959 in MainWindow::findTextCodecs (this=0x7fffecdfd390) at wireshark-3.6.5/ui/qt/main_window.cpp:2029
    #1  0x00005555557b4ce3 in MainWindow::MainWindow (this=this@entry=0x7fffecdfd390, parent=parent@entry=0x0) at wireshark-3.6.5/ui/qt/main_window.cpp:362
    #2  0x000055555564f0af in main (argc=<optimized out>, qt_argv=0x7fffffffe748) at wireshark-3.6.5/ui/qt/main.cpp:725

See https://gitlab.alpinelinux.org/alpine/aports/-/issues/13814 for more
information.

Conflicts (cherry-picked from 635286ce):
	ui/qt/main_window.cpp
This commit is contained in:
Jakub Jirutka 2022-05-18 01:55:53 +02:00 committed by Gerald Combs
parent fe4210029a
commit 3187fbbd61
2 changed files with 14 additions and 0 deletions

View File

@ -2036,6 +2036,13 @@ void LogwolfMainWindow::findTextCodecs() {
QRegularExpressionMatch match;
for (int mib : mibs) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
// QTextCodec::availableMibs() returns a list of hard-coded MIB
// numbers, it doesn't check if they are really available. ICU data may
// not have been compiled with support for all encodings.
if (!codec) {
continue;
}
QString key = codec->name().toUpper();
char rank;

View File

@ -2067,6 +2067,13 @@ void WiresharkMainWindow::findTextCodecs() {
QRegularExpressionMatch match;
for (int mib : mibs) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
// QTextCodec::availableMibs() returns a list of hard-coded MIB
// numbers, it doesn't check if they are really available. ICU data may
// not have been compiled with support for all encodings.
if (!codec) {
continue;
}
QString key = codec->name().toUpper();
char rank;