Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-10-06 08:01:12 +0300
committerPaul B Mahol <onemda@gmail.com>2019-10-07 23:27:17 +0300
commit69dd8d3a2a3d82ada344c889cbf8a8837a9157a0 (patch)
treeb95129e9aaf549f866c1be7d687845a8e1dd5359 /libavformat/flac_picture.c
parent4cb124a800d0150f7a632b4a61bc7449f8562e2d (diff)
avformat/flac_picture: Avoid allocation of AVIOContext
Put an AVIOContext whose lifetime doesn't extend beyond the function where it is allocated on the stack instead of allocating and freeing it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/flac_picture.c')
-rw-r--r--libavformat/flac_picture.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/libavformat/flac_picture.c b/libavformat/flac_picture.c
index 8317ab2fa6..f0871d9c79 100644
--- a/libavformat/flac_picture.c
+++ b/libavformat/flac_picture.c
@@ -26,6 +26,7 @@
#include "flac_picture.h"
#include "id3v2.h"
#include "internal.h"
+#include "avio_internal.h"
int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
{
@@ -33,15 +34,13 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
enum AVCodecID id = AV_CODEC_ID_NONE;
AVBufferRef *data = NULL;
uint8_t mimetype[64], *desc = NULL;
- AVIOContext *pb = NULL;
+ AVIOContext pb0, *pb = &pb0;
AVStream *st;
int width, height, ret = 0;
int len;
unsigned int type;
- pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
- if (!pb)
- return AVERROR(ENOMEM);
+ ffio_init_context(pb, buf, buf_size, 0, NULL, NULL, NULL, NULL);
/* read the picture type */
type = avio_rb32(pb);
@@ -145,14 +144,11 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
- avio_context_free(&pb);
-
return 0;
fail:
av_buffer_unref(&data);
av_freep(&desc);
- avio_context_free(&pb);
return ret;
}