From 6d1d3e928efb2ca5c983d31890dba56ebd10da91 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 5 Dec 2003 11:29:54 +0000 Subject: [PATCH] Allocate memory for parsed command line properly. --- src/mkvmerge.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mkvmerge.cpp b/src/mkvmerge.cpp index ceabb103e..e2c25641d 100644 --- a/src/mkvmerge.cpp +++ b/src/mkvmerge.cpp @@ -865,7 +865,7 @@ static void parse_language(char *s, language_t &lang, const char *opt, mxerror("'%s' is not a valid ISO639-2 code. See " "'mkvmerge --list-languages'.\n", s); - lang.language = s; + lang.language = safestrdup(s); } static void parse_sub_charset(char *s, language_t &sub_charset) { @@ -887,7 +887,7 @@ static void parse_sub_charset(char *s, language_t &sub_charset) { mxerror("Invalid sub charset specified in '--sub-charset %s'.\n", orig.c_str()); - sub_charset.language = s; + sub_charset.language = safestrdup(s); } static void parse_tags(char *s, tags_t &tags, const char *opt) { @@ -907,7 +907,7 @@ static void parse_tags(char *s, tags_t &tags, const char *opt) { mxerror("Invalid tags file name specified in '%s %s'.\n", opt, orig.c_str()); - tags.file_name = s; + tags.file_name = safestrdup(s); } static void parse_fourcc(char *s, const char *opt, track_info_c &ti) { @@ -1740,11 +1740,14 @@ static void parse_args(int argc, char **argv) { i++; } else if (!strcmp(this_arg, "--track-name")) { + char *utf8; if (next_arg == NULL) mxerror("'--track-name' lacks its argument.\n"); parse_language(next_arg, lang, "track-name", "track name", false); - lang.language = to_utf8(cc_command_line, lang.language); + utf8 = to_utf8(cc_command_line, lang.language); + safefree(lang.language); + lang.language = utf8; ti->track_names->push_back(lang); i++;