diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-10-10 19:07:26 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-10-11 22:09:22 +0200 |
commit | 2eec954d10396fba1755261f3d911701818755d8 (patch) | |
tree | 44909df9ddc29391c05cfc510ccab97026af87f4 /lib/sqfs/src | |
parent | a4d371f85ff05c99ce20b7ec49df15cfec11d915 (diff) |
libsqfs: Rework the buffer advance logic for sqfs_istream_t
Remove the asserts. If we eat more data than present, reset the
offset and count to zero.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/src')
-rw-r--r-- | lib/sqfs/src/io/istream.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/sqfs/src/io/istream.c b/lib/sqfs/src/io/istream.c index 7e1b896..6b9388f 100644 --- a/lib/sqfs/src/io/istream.c +++ b/lib/sqfs/src/io/istream.c @@ -113,11 +113,12 @@ static void file_advance_buffer(sqfs_istream_t *strm, size_t count) { file_istream_t *file = (file_istream_t *)strm; - assert(count <= file->buffer_used); - - file->buffer_offset += count; - - assert(file->buffer_offset <= file->buffer_used); + if (count < (file->buffer_used - file->buffer_offset)) { + file->buffer_offset += count; + } else { + file->buffer_offset = 0; + file->buffer_used = 0; + } } static const char *file_get_filename(sqfs_istream_t *strm) |