Two kinds of errors can happen when working with dynamic buffers:
(Re)allocation errors or truncation errors (one has to truncate the
buffer to a size of INT_MAX because avio_close_dyn_buf() and
avio_get_dyn_buf() both return an int). Right now, avio_get_dyn_buf()
returns an empty buffer in either case. But given that
avio_get_dyn_buf() does not destroy the dynamic buffer, one can return
the buffer in case of truncation and let the user check the error flags
and decide for himself instead of hardcoding a single way to proceed
in case of truncation.
(This actually restores the behaviour from before commit
163bb9ac0af495a5cb95441bdb5c02170440d28c.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
{
DynBuffer *d;
- if (!s || s->error) {
+ if (!s) {
*pbuffer = NULL;
return 0;
}
d = s->opaque;
- if (!d->size) {
+ if (!s->error && !d->size) {
*pbuffer = d->io_buffer;
return FFMAX(s->buf_ptr, s->buf_ptr_max) - s->buffer;
}