mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
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:
parent
d2f1b1a3df
commit
3929a71cd0
@ -375,6 +375,7 @@ string Formats::getFormatFromFile(FileName const & filename) const
|
|||||||
return string();
|
return string();
|
||||||
|
|
||||||
#ifdef HAVE_MAGIC_H
|
#ifdef HAVE_MAGIC_H
|
||||||
|
if (filename.exists()) {
|
||||||
magic_t magic_cookie = magic_open(MAGIC_MIME);
|
magic_t magic_cookie = magic_open(MAGIC_MIME);
|
||||||
if (magic_cookie) {
|
if (magic_cookie) {
|
||||||
string format;
|
string format;
|
||||||
@ -402,6 +403,7 @@ string Formats::getFormatFromFile(FileName const & filename) const
|
|||||||
if (!format.empty())
|
if (!format.empty())
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string const format = guessFormatFromContents(filename);
|
string const format = guessFormatFromContents(filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user