From: van Date: Wed, 28 Jan 2009 00:46:54 +0000 (+0000) Subject: Don't let an invalid PES header length (from a corrupted packet) cause us to crash... X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=8d504c772777e38a76aa202d65f7d6c55c723f99;p=handbrake-jp%2Fhandbrake-jp-git.git Don't let an invalid PES header length (from a corrupted packet) cause us to crash in memcpy. git-svn-id: svn://localhost/HandBrake/trunk@2103 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/stream.c b/libhb/stream.c index 5f3358a6..b50dff15 100755 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -2081,16 +2081,17 @@ static void hb_ts_stream_find_pids(hb_stream_t *stream) static void fwrite64( hb_stream_t *stream, void *buf, int len ) { - int pos; - - pos = stream->fwrite_buf->size; - if ( pos + len > stream->fwrite_buf->alloc ) + if ( len > 0 ) { - int size = MAX(stream->fwrite_buf->alloc * 2, pos + len); - hb_buffer_realloc(stream->fwrite_buf, size); + int pos = stream->fwrite_buf->size; + if ( pos + len > stream->fwrite_buf->alloc ) + { + int size = MAX(stream->fwrite_buf->alloc * 2, pos + len); + hb_buffer_realloc(stream->fwrite_buf, size); + } + memcpy( &(stream->fwrite_buf->data[pos]), buf, len ); + stream->fwrite_buf->size += len; } - memcpy( &(stream->fwrite_buf->data[pos]), buf, len ); - stream->fwrite_buf->size += len; } // convert a PES PTS or DTS to an int64