[pandoc warning] Duplicate link reference `[1]' "source" (line 53, column 1)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hello Shaleen,</p>
<p>On 2017-04-14 10:32, Shaleen Jain wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> fixes bug: https://trac.videolan.org/vlc/ticket/11813
mkv spec: https://www.matroska.org/technical/specs/index.html#languages
---
modules/demux/mkv/matroska_segment_parse.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index f4d73613c9..705a5baab0 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -379,9 +379,14 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
}
E_CASE( KaxTrackLanguage, lang )
{
- free( vars.tk->fmt.psz_language );
- vars.tk->fmt.psz_language = strdup( std::string( lang ).c_str() );
- debug( vars, "Track Language=`%s'", vars.tk->fmt.psz_language );
+ free(vars.tk->fmt.psz_language);
+ char* psz_lang = strdup(std::string(lang).c_str());
+ if (psz_lang != NULL && strchr(psz_lang, '-') != NULL) {
+ vars.tk->fmt.psz_language = strtok(psz_lang, "-");
+ } else {
+ vars.tk->fmt.psz_language = psz_lang;
+ }
+ debug(vars, "Track Language=`%s'", vars.tk->fmt.psz_language );</code></pre>
</blockquote>
<p>As implied by my earlier message, please use the C++ utilities available for making this work, or take Jean-Baptiste’s <a href="https://mailman.videolan.org/pipermail/vlc-devel/2017-April/112856.html">advice</a>, and use a helper available in <code><vlc_iso_long.h></code>.</p>
<p>Given that you did not take neither of the adviced paths, see the below for an example of a functionally equivalent implementation to yours.</p>
<pre><code>std::string const& slang ( lang );
free( vars.tk->fmt.psz_language );
vars.tk->fmt.psz_language = strndup( slang.c_str (),
slang.find_first_of( '-' ) );</code></pre>
<p>As I expected you to move to C++ utilities I did not bother to point out the problem in terms of thread-safety with <code>strtok</code>; but it is important for you to note that <em>Rémi</em> is of course correct with his remark, and that your reasoning in <a href="https://mailman.videolan.org/pipermail/vlc-devel/2017-April/112856.html">the reply to his message</a> is wrong.</p>
<p>Best Regards,<br />
Filip</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> }
E_CASE( KaxCodecID, codecid )
{
--
2.12.2
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
https://mailman.videolan.org/listinfo/vlc-devel</code></pre>
</blockquote>
</body>
</html>