summaryrefslogtreecommitdiff
path: root/libavformat/rmdec.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2018-04-02 22:09:59 +0200
committerPaul B Mahol <onemda@gmail.com>2018-04-02 22:44:26 +0200
commit46129b40446a802b0b5da4797709f552b68b48f5 (patch)
tree5b469593a20d9ad0b403615b1588302948f7803f /libavformat/rmdec.c
parent37d472a906bd9112225129fc35d9c94ae2ee9c3e (diff)
downloadffmpeg-46129b40446a802b0b5da4797709f552b68b48f5.tar.gz
avformat/rmdec: make use of avio_get_str()
Also do not set empty metadata. Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/rmdec.c')
-rw-r--r--libavformat/rmdec.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index fea71a2fc9..ac61723c66 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -70,16 +70,10 @@ static int rm_read_close(AVFormatContext *s);
static inline void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
{
- int i;
- char *q, r;
+ int read = avio_get_str(pb, len, buf, buf_size);
- q = buf;
- for(i=0;i<len;i++) {
- r = avio_r8(pb);
- if (i < buf_size - 1)
- *q++ = r;
- }
- if (buf_size > 0) *q = '\0';
+ if (read > 0)
+ avio_skip(pb, len - read);
}
static void get_str8(AVIOContext *pb, char *buf, int buf_size)
@@ -105,8 +99,10 @@ static void rm_read_metadata(AVFormatContext *s, AVIOContext *pb, int wide)
for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
int len = wide ? avio_rb16(pb) : avio_r8(pb);
- get_strl(pb, buf, sizeof(buf), len);
- av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);
+ if (len > 0) {
+ get_strl(pb, buf, sizeof(buf), len);
+ av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);
+ }
}
}