if (rt->out_size + size > rt->out_capacity) {
int err;
rt->out_capacity = (rt->out_size + size) * 2;
- if ((err = av_reallocp(&rt->out_data, rt->out_capacity)) < 0)
+ if ((err = av_reallocp(&rt->out_data, rt->out_capacity)) < 0) {
+ rt->out_size = 0;
+ rt->out_capacity = 0;
return err;
+ }
}
memcpy(rt->out_data + rt->out_size, buf, size);
if (ret < 0 && ret != AVERROR_EOF)
return ret;
- if (ret == AVERROR_EOF) {
+ if (!ret || ret == AVERROR_EOF) {
if (rt->finishing) {
/* Do not send new requests when the client wants to
* close the connection. */
/* read the server reply which contains a unique ID */
for (;;) {
ret = ffurl_read(rt->stream, rt->client_id + off, sizeof(rt->client_id) - off);
- if (ret == AVERROR_EOF)
+ if (!ret || ret == AVERROR_EOF)
break;
if (ret < 0)
goto fail;