From 7f656b5108e4278116fd7103c2974919d8301713 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 21 Aug 2004 09:42:38 +0000 Subject: [PATCH] Merged 2002:2004 --- ChangeLog | 7 +++++++ src/common/chapter_parser_xml.cpp | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b7934842..9c70d8f03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-08-21 Moritz Bunkus + + * mkvmerge: bug fix: Use 'setjmp' and 'longjmp' Instead of + throwing a C++ exception during the chapter parsing + stage. Otherwise libexpat will abort with a non-descriptive error + message on Windows. + 2004-08-20 Moritz Bunkus * mkvmerge: bug fix: SSA/ASS subs with the old codec ID 'S_SSA' diff --git a/src/common/chapter_parser_xml.cpp b/src/common/chapter_parser_xml.cpp index 61e67a5ee..a1ef76198 100644 --- a/src/common/chapter_parser_xml.cpp +++ b/src/common/chapter_parser_xml.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -42,6 +43,9 @@ typedef struct { vector *parents; KaxChapters *chapters; + + jmp_buf parse_error_jmp; + string *parse_error_msg; } parser_data_t; // {{{ XML chapters @@ -81,7 +85,9 @@ cperror(parser_data_t *pdata, vsprintf(&new_string[strlen(new_string)], new_fmt.c_str(), ap); va_end(ap); strcat(new_string, "\n"); - throw error_c(new_string, true); + *pdata->parse_error_msg = new_string; + safefree(new_string); + longjmp(pdata->parse_error_jmp, 1); } #define el_get_bool(pdata, el) el_get_uint(pdata, el, 0, true) @@ -731,6 +737,7 @@ parse_xml_chapters(mm_text_io_c *in, pdata->parser = parser; pdata->file_name = in->get_file_name(); pdata->parents = new vector; + pdata->parse_error_msg = new string; XML_SetUserData(parser, pdata); XML_SetElementHandler(parser, start_element, end_element); @@ -741,6 +748,8 @@ parse_xml_chapters(mm_text_io_c *in, error = ""; try { + if (setjmp(pdata->parse_error_jmp) == 1) + throw error_c(*pdata->parse_error_msg); done = !in->getline2(buffer); while (!done) { buffer += "\n"; @@ -753,8 +762,8 @@ parse_xml_chapters(mm_text_io_c *in, error += "Remember that special characters like &, <, > and \" " "must be escaped in the usual HTML way: & for '&', " "< for '<', > for '>' and " for '\"'. "; - error += "Aborting."; - throw error_c(error.c_str()); + error += "Aborting.\n"; + throw error_c(error); } done = !in->getline2(buffer); @@ -776,6 +785,7 @@ parse_xml_chapters(mm_text_io_c *in, XML_ParserFree(parser); delete pdata->parents; + delete pdata->parse_error_msg; safefree(pdata); if ((chapters != NULL) && (verbose > 1))