From f84a88952e791163a25190a1010cbade93bcc1c6 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 12 Nov 2006 13:30:11 +0000 Subject: [PATCH] --attach-file: Test if the file can be read before trying to guess its MIME type because libmagic segfaults if it does not. --- ChangeLog | 4 ++++ src/merge/mkvmerge.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 98ef1c9b8..65fa43f85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-11-12 Moritz Bunkus + * 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. diff --git a/src/merge/mkvmerge.cpp b/src/merge/mkvmerge.cpp index d867feec3..0424ef1c0 100644 --- a/src/merge/mkvmerge.cpp +++ b/src/merge/mkvmerge.cpp @@ -1610,6 +1610,14 @@ parse_args(vector 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);