#define configSTACK_DEPTH_TYPE uint16_t\r
#endif\r
\r
+#ifndef configMESSAGE_BUFFER_LENGTH_TYPE\r
+ /* Defaults to size_t for backward compatibility, but can be overridden\r
+ in FreeRTOSConfig.h if lengths will always be less than the number of bytes\r
+ in a size_t. */\r
+ #define configMESSAGE_BUFFER_LENGTH_TYPE size_t\r
+#endif\r
+\r
/* Sanity check the configuration. */\r
#if( configUSE_TICKLESS_IDLE != 0 )\r
#if( INCLUDE_vTaskSuspend != 1 )\r
/*lint -restore (9026) */\r
\r
/* The number of bytes used to hold the length of a message in the buffer. */\r
-#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) )\r
+#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )\r
\r
/* Bits stored in the ucFlags field of the stream buffer. */\r
#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */\r
if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
{\r
xRequiredSpace += sbBYTES_TO_STORE_MESSAGE_LENGTH;\r
+\r
+ /* Overflow? */\r
+ configASSERT( xRequiredSpace > xDataLengthBytes );\r
}\r
else\r
{\r
returned to its prior state if the length of the message is too\r
large for the provided buffer. */\r
xOriginalTail = pxStreamBuffer->xTail;\r
+ /* Ensure xNextMessageLength is cleared to 0 in case\r
+ sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) != sizeof( size_t ). */\r
+ xNextMessageLength = 0;\r
( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );\r
\r
/* Reduce the number of bytes available by the number of bytes just\r