Avoid crash in call to magic_file() if the checked file does not exist

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40803 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Kornel Benko 2012-02-28 15:21:46 +00:00
parent d2f1b1a3df
commit 3929a71cd0

View File

@ -375,6 +375,7 @@ string Formats::getFormatFromFile(FileName const & filename) const
return string();
#ifdef HAVE_MAGIC_H
if (filename.exists()) {
magic_t magic_cookie = magic_open(MAGIC_MIME);
if (magic_cookie) {
string format;
@ -402,6 +403,7 @@ string Formats::getFormatFromFile(FileName const & filename) const
if (!format.empty())
return format;
}
}
#endif
string const format = guessFormatFromContents(filename);