Skip to content

Inconsistent documentation for xStreamBufferCreateStatic() #379

Closed
@paul-igor

Description

@paul-igor

In stream_buffer.h, the documentation for xStreamBufferCreateStatic() describes the first and third parameters as follows:

 * @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the
 * pucStreamBufferStorageArea parameter.
 * @param pucStreamBufferStorageArea Must point to a uint8_t array that is at
 * least xBufferSizeBytes + 1 big.  This is the array to which streams are
 * copied when they are written to the stream buffer.

However, in the example that follows in the header file, the crucial +1 seems to have been omitted. This can result in an off-by-one issue that overflows the buffer. When following the example, my team's project experienced a crash that was difficult to narrow down.

 *  xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ),
 *                                             xTriggerLevel,
 *                                             ucBufferStorage,
 *                                             &xStreamBufferStruct );

A similar documentation pattern appears in message_buffer.h for xMessageBufferCreateStatic(). Maybe there are others?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions