Don't use bio_writer_t.skip() to write length field when appending more data
If the writer reallocates its buffer, the length pointer might not be valid anymore, or even worse, point to an arbitrary allocation.
This commit is contained in:
@@ -126,8 +126,11 @@ struct bio_writer_t {
|
||||
void (*wrap32)(bio_writer_t *this);
|
||||
|
||||
/**
|
||||
* Skips len bytes in the buffer before the next data is written, returns
|
||||
* a chunk covering the skipped bytes.
|
||||
* Skips len bytes in the buffer, return chunk of skipped data.
|
||||
*
|
||||
* The returned chunk is not valid after calling any other writer function
|
||||
* (except get_buf()), because a buffer reallocation might move the
|
||||
* internal buffer to a different memory location!
|
||||
*
|
||||
* @param len number of bytes to skip
|
||||
* @return chunk pointing to skipped bytes in the internal buffer
|
||||
|
||||
Reference in New Issue
Block a user