History

avformat/vqf: Propagate errors from add_metadata()

Michael Niedermayer committed 1 year ago

Commit 49fa3f61 parent c43dbec1 file · +14 −7Browse files

Unified · Split

libavformat/vqf.c+14−7
@@ -51,23 +51,28 @@ static int vqf_probe(const AVProbeData *probe_packet) · 50 unmodified lines
51 return AVPROBE_SCORE_EXTENSION;51 return AVPROBE_SCORE_EXTENSION;
52}52}
53 53
54static void add_metadata(AVFormatContext *s, uint32_t tag,54static int add_metadata(AVFormatContext *s, uint32_t tag,
55 unsigned int tag_len, unsigned int remaining)55 unsigned int tag_len, unsigned int remaining)
56{56{
57 int len = FFMIN(tag_len, remaining);57 int len = FFMIN(tag_len, remaining);
58 char *buf, key[5] = {0};58 char *buf, key[5] = {0};
59 int ret;
59 60
60 if (len == UINT_MAX)61 if (len == UINT_MAX)
61 return;62 return AVERROR_INVALIDDATA;
62 63
63 buf = av_malloc(len+1);64 buf = av_malloc(len+1);
64 if (!buf)65 if (!buf)
65 return;66 return AVERROR(ENOMEM);
66 if (len != avio_read(s->pb, buf, len))67
67 return;68 ret = avio_read(s->pb, buf, len);
69 if (ret < 0)
70 return ret;
71 if (len != ret)
72 return AVERROR_INVALIDDATA;
68 buf[len] = 0;73 buf[len] = 0;
69 AV_WL32(key, tag);74 AV_WL32(key, tag);
70 av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL);75 return av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL);
71}76}
72 77
73static const AVMetadataConv vqf_metadata_conv[] = {78static const AVMetadataConv vqf_metadata_conv[] = {
@@ -165,7 +170,9 @@ static int vqf_read_header(AVFormatContext *s) · 91 unmodified lines
165 avio_skip(s->pb, FFMIN(len, header_size));170 avio_skip(s->pb, FFMIN(len, header_size));
166 break;171 break;
167 default:172 default:
168 add_metadata(s, chunk_tag, len, header_size);173 ret = add_metadata(s, chunk_tag, len, header_size);
174 if (ret < 0)
175 return ret;
169 break;176 break;
170 }177 }
171 178

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t