[vlc-commits] mkv: Don't pass std::string::npos to strndup
Hugo Beauzée-Luyssen
git at videolan.org
Thu May 11 11:23:00 CEST 2017
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu May 11 11:21:30 2017 +0200| [94fcc7f7f01866e03d10e347a3efbacb1cf2055d] | committer: Hugo Beauzée-Luyssen
mkv: Don't pass std::string::npos to strndup
This seems to "confuse" some libc
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94fcc7f7f01866e03d10e347a3efbacb1cf2055d
---
modules/demux/mkv/matroska_segment_parse.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index d2dd03008e..f5a4ca349f 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -381,7 +381,8 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
{
free( vars.tk->fmt.psz_language );
const std::string slang ( lang );
- vars.tk->fmt.psz_language = strndup( slang.c_str (), slang.find_first_of( '-' ) );
+ size_t pos = slang.find_first_of( '-' );
+ vars.tk->fmt.psz_language = pos != std::string::npos ? strndup( slang.c_str (), pos ) : strdup( slang.c_str() );
debug( vars, "Track Language=`%s'", vars.tk->fmt.psz_language ? vars.tk->fmt.psz_language : "(null)" );
}
E_CASE( KaxCodecID, codecid )
More information about the vlc-commits
mailing list