summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-11-27 10:50:47 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-03 16:07:02 +0100
commita4798a5d5109cd9c1b5682efe19660e825da97e6 (patch)
treec91e38e738cf12d468e06aaba77738173eed75e1 /libavformat
parentb574fb472ed168f5a75cd981c98dd34cfe57ff3a (diff)
all: Use av_memdup() where appropriate
Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/hdsenc.c6
-rw-r--r--libavformat/mpegts.c3
-rw-r--r--libavformat/oggparsevorbis.c3
-rw-r--r--libavformat/rtsp.c3
4 files changed, 5 insertions, 10 deletions
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index e5353bac65..64d9f1413d 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -93,19 +93,17 @@ static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size)
if (os->nb_extra_packets >= FF_ARRAY_ELEMS(os->extra_packets))
return AVERROR_INVALIDDATA;
os->extra_packet_sizes[os->nb_extra_packets] = size;
- os->extra_packets[os->nb_extra_packets] = av_malloc(size);
+ os->extra_packets[os->nb_extra_packets] = av_memdup(buf, size);
if (!os->extra_packets[os->nb_extra_packets])
return AVERROR(ENOMEM);
- memcpy(os->extra_packets[os->nb_extra_packets], buf, size);
os->nb_extra_packets++;
} else if (type == 0x12) {
if (os->metadata)
return AVERROR_INVALIDDATA;
os->metadata_size = size - 11 - 4;
- os->metadata = av_malloc(os->metadata_size);
+ os->metadata = av_memdup(buf + 11, os->metadata_size);
if (!os->metadata)
return AVERROR(ENOMEM);
- memcpy(os->metadata, buf + 11, os->metadata_size);
}
buf += size;
buf_size -= size;
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 36ab7ab3af..2479cb6f7d 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -938,10 +938,9 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
// audio track - add a second stream for this
AVStream *sub_st;
// priv_data cannot be shared between streams
- PESContext *sub_pes = av_malloc(sizeof(*sub_pes));
+ PESContext *sub_pes = av_memdup(pes, sizeof(*sub_pes));
if (!sub_pes)
return AVERROR(ENOMEM);
- memcpy(sub_pes, pes, sizeof(*sub_pes));
sub_st = avformat_new_stream(pes->stream, NULL);
if (!sub_st) {
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 77e8d301b2..e1ef510892 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -320,10 +320,9 @@ static int vorbis_header(AVFormatContext *s, int idx)
return priv->vp ? 0 : AVERROR_INVALIDDATA;
priv->len[pkt_type >> 1] = os->psize;
- priv->packet[pkt_type >> 1] = av_mallocz(os->psize);
+ priv->packet[pkt_type >> 1] = av_memdup(os->buf + os->pstart, os->psize);
if (!priv->packet[pkt_type >> 1])
return AVERROR(ENOMEM);
- memcpy(priv->packet[pkt_type >> 1], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) {
const uint8_t *p = os->buf + os->pstart + 7; /* skip "\001vorbis" tag */
unsigned blocksize, bs0, bs1;
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index e6a4993acd..cd3d284da6 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -387,10 +387,9 @@ static void copy_default_source_addrs(struct RTSPSource **addrs, int count,
int i;
for (i = 0; i < count; i++) {
rtsp_src = addrs[i];
- rtsp_src2 = av_malloc(sizeof(*rtsp_src2));
+ rtsp_src2 = av_memdup(rtsp_src, sizeof(*rtsp_src));
if (!rtsp_src2)
continue;
- memcpy(rtsp_src2, rtsp_src, sizeof(*rtsp_src));
dynarray_add(dest, dest_count, rtsp_src2);
}
}