summaryrefslogtreecommitdiff
path: root/libavformat/rtpdec_h264.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2015-02-19 21:12:06 +0200
committerMartin Storsjö <martin@martin.st>2015-02-20 19:29:29 +0200
commit7650caf013f45ebebf128855735a0c6350836ea4 (patch)
tree14a73725cb93c3484359cc6d9cd59d50171c5f49 /libavformat/rtpdec_h264.c
parent8bdbf49c6f4d9473183a3c45ec70d611eb6183cd (diff)
rtpdec_h264: Use av_realloc instead of av_malloc+mempcy
This is similar to what was done for rtpdec_hevc in ced7238cd01. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpdec_h264.c')
-rw-r--r--libavformat/rtpdec_h264.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index 7abfde7365..d24fa3246b 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -115,18 +115,16 @@ static int parse_sprop_parameter_sets(AVFormatContext *s,
packet_size = av_base64_decode(decoded_packet, base64packet,
sizeof(decoded_packet));
if (packet_size > 0) {
- uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) +
- codec->extradata_size +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ uint8_t *dest = av_realloc(codec->extradata,
+ packet_size + sizeof(start_sequence) +
+ codec->extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
if (!dest) {
av_log(s, AV_LOG_ERROR,
"Unable to allocate memory for extradata!\n");
return AVERROR(ENOMEM);
}
- if (codec->extradata_size) {
- memcpy(dest, codec->extradata, codec->extradata_size);
- av_free(codec->extradata);
- }
+ codec->extradata = dest;
memcpy(dest + codec->extradata_size, start_sequence,
sizeof(start_sequence));
@@ -135,7 +133,6 @@ static int parse_sprop_parameter_sets(AVFormatContext *s,
memset(dest + codec->extradata_size + sizeof(start_sequence) +
packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- codec->extradata = dest;
codec->extradata_size += sizeof(start_sequence) + packet_size;
}
}