summaryrefslogtreecommitdiffstats
path: root/libhb/stream.c
diff options
context:
space:
mode:
authorvan <[email protected]>2009-01-28 00:46:54 +0000
committervan <[email protected]>2009-01-28 00:46:54 +0000
commit271785001bdd9c7387649b62ab62823964d13c8c (patch)
tree9b64fb5a94fae6e42412ecc87810732f57f0601f /libhb/stream.c
parentfc2ebc097b3c2227113719e707bed0b4f10c8e27 (diff)
Don't let an invalid PES header length (from a corrupted packet) cause us to crash in memcpy.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2103 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rwxr-xr-xlibhb/stream.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libhb/stream.c b/libhb/stream.c
index 5f3358a6d..b50dff15e 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