Checks for some buffer overruns
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1396 e3e1d417-86f3-4887-817a-d78f3d33393fpull/27/merge
parent
a1006edcbd
commit
322caab34b
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue