Commit 9fee37c5 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

avformat/img2dec: Avoid duplicating buffer when adding side-data

Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent be22f973
...@@ -379,8 +379,7 @@ int ff_img_read_header(AVFormatContext *s1) ...@@ -379,8 +379,7 @@ int ff_img_read_header(AVFormatContext *s1)
* as a dictionary, so it can be used by filters like 'drawtext'. * as a dictionary, so it can be used by filters like 'drawtext'.
*/ */
static int add_filename_as_pkt_side_data(char *filename, AVPacket *pkt) { static int add_filename_as_pkt_side_data(char *filename, AVPacket *pkt) {
uint8_t* metadata; int metadata_len, ret;
int metadata_len;
AVDictionary *d = NULL; AVDictionary *d = NULL;
char *packed_metadata = NULL; char *packed_metadata = NULL;
...@@ -391,13 +390,12 @@ static int add_filename_as_pkt_side_data(char *filename, AVPacket *pkt) { ...@@ -391,13 +390,12 @@ static int add_filename_as_pkt_side_data(char *filename, AVPacket *pkt) {
av_dict_free(&d); av_dict_free(&d);
if (!packed_metadata) if (!packed_metadata)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (!(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, metadata_len))) { ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
packed_metadata, metadata_len);
if (ret < 0) {
av_freep(&packed_metadata); av_freep(&packed_metadata);
return AVERROR(ENOMEM); return ret;
} }
memcpy(metadata, packed_metadata, metadata_len);
av_freep(&packed_metadata);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment