Checks for some buffer overruns

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1396 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2005-05-05 16:43:36 +00:00
parent a1006edcbd
commit 322caab34b
1 changed files with 10 additions and 0 deletions

View File

@ -83,12 +83,22 @@ public:
unsigned int Consume( unsigned int count )
{
if ( count > size )
{
Warning(( "Attempt to consume %d bytes of buffer, size is only %d bytes", count, size ));
count = size;
}
head += count;
size -= count;
return( size );
}
unsigned int Shrink( unsigned int count )
{
if ( count > size )
{
Warning(( "Attempt to shrink buffer by %d bytes, size is only %d bytes", count, size ));
count = size;
}
size -= count;
if ( tail > head + size )
tail = head + size;