Commit 50eec8a4 authored by Steve Lhomme's avatar Steve Lhomme

demux:mkv: fix potential buffer size issues

Ref CID #1465525
parent 14251937
...@@ -388,13 +388,13 @@ void MkvTree_va( demux_t& demuxer, int i_level, const char* fmt, va_list args) ...@@ -388,13 +388,13 @@ void MkvTree_va( demux_t& demuxer, int i_level, const char* fmt, va_list args)
{ {
static char const * indent = "| "; static char const * indent = "| ";
static char const * prefix = "+ "; static char const * prefix = "+ ";
static int const indent_len = strlen( indent ); static int const indent_len = sizeof( indent );
static int const prefix_len = strlen( prefix ); static int const prefix_len = sizeof( prefix );
char fixed_buffer[256] = {}; char fixed_buffer[256] = {};
size_t const static_len = sizeof( fixed_buffer ); size_t const static_len = sizeof( fixed_buffer );
char * buffer = fixed_buffer; char * buffer = fixed_buffer;
size_t total_len = indent_len * i_level + prefix_len + strlen( fmt ); size_t total_len = indent_len * i_level + prefix_len + strlen( fmt ) + 1;
if( total_len >= static_len ) { if( total_len >= static_len ) {
buffer = new (std::nothrow) char[total_len] (); buffer = new (std::nothrow) char[total_len] ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment