Fix null pointer dereference in QtMessageHandler function
The `QMessageLogContext` is only filled out in debug builds. Release builds will have null pointers in `file` and `line`. This causes any error attempted to be logged to result in a null pointer dereference. Since we never use debug builds anyway, simply removing the uses of `file` and `line` makes sense. Github issue https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/issues/139
This commit is contained in:
+9
-10
@@ -7,28 +7,27 @@ void mainQtMessageHandler( QtMsgType type,
|
||||
const QMessageLogContext& context,
|
||||
const QString& msg )
|
||||
{
|
||||
// context contains null pointers on release builds. Cast to get rid of
|
||||
// unreferenced formal parameter warnings.
|
||||
static_cast<void>( context );
|
||||
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
switch ( type )
|
||||
{
|
||||
case QtDebugMsg:
|
||||
LOG( DEBUG ) << localMsg.constData() << " (" << context.file << ":"
|
||||
<< context.line << ")";
|
||||
LOG( DEBUG ) << localMsg.constData();
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
LOG( INFO ) << localMsg.constData() << " (" << context.file << ":"
|
||||
<< context.line << ")";
|
||||
LOG( INFO ) << localMsg.constData();
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
LOG( WARNING ) << localMsg.constData() << " (" << context.file << ":"
|
||||
<< context.line << ")";
|
||||
LOG( WARNING ) << localMsg.constData();
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
LOG( ERROR ) << localMsg.constData() << " (" << context.file << ":"
|
||||
<< context.line << ")";
|
||||
LOG( ERROR ) << localMsg.constData();
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
LOG( FATAL ) << localMsg.constData() << " (" << context.file << ":"
|
||||
<< context.line << ")";
|
||||
LOG( FATAL ) << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user