rwops_zstd: fix decoding of small streams

This commit is contained in:
Andrei Alexeyev 2021-03-25 20:53:28 +02:00
parent fff174e99d
commit 3df55eb6ac
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -157,13 +157,15 @@ static size_t rwzstd_read(SDL_RWops *rw, void *ptr, size_t size, size_t maxnum)
};
ZSTD_DStream *stream = NOT_NULL(z->reader.stream);
while(out.pos < out.size) {
bool have_input = true;
while(out.pos < out.size && have_input) {
if(in->size - in->pos < z->reader.next_read_size) {
rwzstd_reader_fill_in_buffer(z, z->reader.next_read_size);
if(in->size - in->pos < z->reader.next_read_size) {
// end of stream
break;
have_input = false;
}
}