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:
Martin Willi
2013-01-11 14:57:08 +01:00
parent 2f0441a3a6
commit 54a1a75b2f
2 changed files with 9 additions and 6 deletions
+5 -2
View File
@@ -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