Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f264146e authored by David Faure's avatar David Faure

Fix crash when arguments().mimeType() is an invalid mimetype name.

I have a JIRA bug report with a PDF attached, and mid-clicking the PDF
in konqueror leads to opening an okularpart with mimetype="application/x-octet-stream"
(the x- in there is very unusual, and unknown to shared-mime-info).
Fixed with null pointer checks.

REVIEW: 122074
parent eb0da16e
......@@ -1325,18 +1325,20 @@ bool Part::openFile()
if ( !isstdin && !fileInfo.exists() )
return false;
KMimeType::Ptr pathMime = KMimeType::findByPath( fileNameToOpen );
if ( !arguments().mimeType().isEmpty() )
const QString argMimeType = arguments().mimeType();
if ( !argMimeType.isEmpty() )
{
KMimeType::Ptr argMime = KMimeType::mimeType( arguments().mimeType() );
KMimeType::Ptr argMime = KMimeType::mimeType( argMimeType );
// Select the "childmost" mimetype, if none of them
// inherits the other trust more what pathMime says
// but still do a second try if that one fails
if ( argMime->is( pathMime->name() ) )
if ( argMime && argMime->is( pathMime->name() ) )
{
mimes << argMime;
}
else if ( pathMime->is( argMime->name() ) )
else if ( !argMime || pathMime->is( argMime->name() ) )
{
mimes << pathMime;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment