From 0d9ffb11fa09acda4ac51575ec409e4b7b7c9c11 Mon Sep 17 00:00:00 2001 From: Simon Wells Date: Fri, 1 Jan 2016 20:51:50 +1300 Subject: [PATCH] Ensure filetype is not null before using open command, Fixed if statements to follow coding guidelines --- common/gestfich.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/gestfich.cpp b/common/gestfich.cpp index da224f3262..adb71c5d4f 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -44,7 +44,7 @@ void AddDelimiterString( wxString& string ) { - if ( !string.StartsWith( wxT( "\"" ) ) ) + if( !string.StartsWith( wxT( "\"" ) ) ) { string.Prepend ( wxT( "\"" ) ); string.Append ( wxT( "\"" ) ); @@ -358,13 +358,16 @@ bool OpenPDF( const wxString& file ) else { wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( "pdf" ) ); - command = filetype->GetOpenCommand( filename ); + + if( filetype ) + command = filetype->GetOpenCommand( filename ); + delete filetype; } - if ( !command.IsEmpty() ) + if( !command.IsEmpty() ) { - if ( ProcessExecute( command ) ) + if( ProcessExecute( command ) ) { return true; }