QUIC application protocol layer has the ability to either allocate a
standard buffer or a smaller one. The latter is useful when only small
data are transferred to prevent consuming too much of the QUIC MUX
buffer window.
This operation is performed using qc_stream_buf_realloc(). Add a new
BUG_ON() in it to ensure no data is present in the buffer. Indeed, this
would cause to data loss, or even crash when trying to acknowledge data.
Note that for the moment qc_stream_buf_realloc() is only use for HTTP/3
headers transmission, and this usage is conform to the new BUG_ON. This
commit is thus not a bug fix, but only to strengthen the API.
/* This function is reserved to convert a big buffer to a smaller one. */
BUG_ON(!stream->buf || !stream->buf->sbuf);
+ /* This function can only be used if targetted buffer is empty. */
+ BUG_ON(b_data(&stream->buf->buf));
+
/* Release buffer */
pool_free(pool_head_sbuf, stream->buf->buf.area);
stream->buf->buf = BUF_NULL;