Skip to content
Permalink
Browse files Browse the repository at this point in the history
Add addition overflow check for stream buffer (#226)
  • Loading branch information
cobusve committed Dec 7, 2020
1 parent c7a9a01 commit d05b9c1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions stream_buffer.c
Expand Up @@ -258,8 +258,16 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
* this is a quirk of the implementation that means otherwise the free
* space would be reported as one byte smaller than would be logically
* expected. */
xBufferSizeBytes++;
pucAllocatedMemory = ( uint8_t * ) pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) ); /*lint !e9079 malloc() only returns void*. */
if( xBufferSizeBytes < ( xBufferSizeBytes + 1 + sizeof( StreamBuffer_t ) ) )
{
xBufferSizeBytes++;
pucAllocatedMemory = ( uint8_t * ) pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) ); /*lint !e9079 malloc() only returns void*. */
}
else
{
pucAllocatedMemory = NULL;
}


if( pucAllocatedMemory != NULL )
{
Expand Down

0 comments on commit d05b9c1

Please sign in to comment.