--attach-file: Test if the file can be read before trying to guess its MIME type because libmagic segfaults if it does not.

This commit is contained in:
Moritz Bunkus 2006-11-12 13:30:11 +00:00
parent f792d7fb66
commit f84a88952e
2 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,9 @@
2006-11-12 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: Fixed a segfault if the file specified with
"--attach-file" does not exist. Bugfix for Anthill bug 213 and
Debian bug 393984.
* mmg: bug fix: Fixed a crash on loading XML chapters after having
saved XML chapters.

View File

@ -1610,6 +1610,14 @@ parse_args(vector<string> args) {
if (no_next_arg)
mxerror(_("'%s' lacks the file name.\n"), this_arg.c_str());
try {
mm_file_io_c test(next_arg);
} catch (...) {
mxerror(_("The file '%s' cannot be attached because "
"it does not exist or cannot be read.\n"),
next_arg.c_str());
}
attachment.name = next_arg;
if (attachment.mime_type == "")
attachment.mime_type = guess_mime_type_and_report(next_arg);