summaryrefslogtreecommitdiff
path: root/libavformat/rtpdec_xiph.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-10 22:59:53 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-12 19:25:33 +0100
commitc1e439d7e9abab3cebdc937636393b1656e095d9 (patch)
treebe0ae941a23b62c42b152e2b9aa0a22f8c793d4e /libavformat/rtpdec_xiph.c
parentcb88cdf7730e309df22ddbbc1ae4ebcd9ebc529e (diff)
downloadffmpeg-c1e439d7e9abab3cebdc937636393b1656e095d9.tar.gz
avformat: Forward errors where possible
It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/rtpdec_xiph.c')
-rw-r--r--libavformat/rtpdec_xiph.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c
index 574508affb..c2db10dab8 100644
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@ -63,7 +63,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
int flags)
{
- int ident, fragmented, tdt, num_pkts, pkt_len;
+ int ident, fragmented, tdt, num_pkts, pkt_len, ret;
if (!buf) {
if (!data->split_buf || data->split_pos + 2 > data->split_buf_len ||
@@ -77,9 +77,9 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
av_log(ctx, AV_LOG_ERROR, "Not enough data to return\n");
return AVERROR_INVALIDDATA;
}
- if (av_new_packet(pkt, pkt_len)) {
+ if ((ret = av_new_packet(pkt, pkt_len)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
- return AVERROR(ENOMEM);
+ return ret;
}
pkt->stream_index = st->index;
memcpy(pkt->data, data->split_buf + data->split_pos, pkt_len);
@@ -123,9 +123,9 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
len -= 6;
if (fragmented == 0) {
- if (av_new_packet(pkt, pkt_len)) {
+ if ((ret = av_new_packet(pkt, pkt_len)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
- return AVERROR(ENOMEM);
+ return ret;
}
pkt->stream_index = st->index;
memcpy(pkt->data, buf, pkt_len);
@@ -228,6 +228,7 @@ parse_packed_headers(AVFormatContext *s,
{
unsigned num_packed, num_headers, length, length1, length2, extradata_alloc;
+ int ret;
uint8_t *ptr;
if (packed_headers_end - packed_headers < 9) {
@@ -264,9 +265,9 @@ parse_packed_headers(AVFormatContext *s,
* -- AV_INPUT_BUFFER_PADDING_SIZE required */
extradata_alloc = length + length/255 + 3 + AV_INPUT_BUFFER_PADDING_SIZE;
- if (ff_alloc_extradata(par, extradata_alloc)) {
+ if ((ret = ff_alloc_extradata(par, extradata_alloc)) < 0) {
av_log(s, AV_LOG_ERROR, "Out of memory\n");
- return AVERROR(ENOMEM);
+ return ret;
}
ptr = par->extradata;
*ptr++ = 2;