Mercurial > libavformat.hg
comparison asfdec.c @ 5446:4211f91f69b1 libavformat
Use AV_METADATA_DONT_STRDUP* / use av_malloced metadata instead of strduped
arrays of fixed length.
Code from ffmbc with changes to adapt to our metadata API.
author | michael |
---|---|
date | Sun, 13 Dec 2009 20:27:29 +0000 |
parents | f292b3e34823 |
children | 09cb78a5b0e4 |
comparison
equal
deleted
inserted
replaced
5445:d1b5bb2bfe92 | 5446:4211f91f69b1 |
---|---|
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 static void get_tag(AVFormatContext *s, const char *key, int type, int len) | 153 static void get_tag(AVFormatContext *s, const char *key, int type, int len) |
154 { | 154 { |
155 char value[1024]; | 155 char *value; |
156 | |
157 if ((unsigned)len >= UINT_MAX) | |
158 return; | |
159 | |
160 value = av_malloc(len+1); | |
161 if (!value) | |
162 return; | |
163 | |
156 if (type <= 1) { // unicode or byte | 164 if (type <= 1) { // unicode or byte |
157 get_str16_nolen(s->pb, len, value, sizeof(value)); | 165 get_str16_nolen(s->pb, len, value, len); |
158 } else if (type <= 5) { // boolean or DWORD or QWORD or WORD | 166 } else if (type <= 5) { // boolean or DWORD or QWORD or WORD |
159 uint64_t num = get_value(s->pb, type); | 167 uint64_t num = get_value(s->pb, type); |
160 snprintf(value, sizeof(value), "%"PRIu64, num); | 168 snprintf(value, len, "%"PRIu64, num); |
161 } else { | 169 } else { |
162 url_fskip(s->pb, len); | 170 url_fskip(s->pb, len); |
163 return; | 171 return; |
164 } | 172 } |
165 if (!strncmp(key, "WM/", 3)) | 173 if (!strncmp(key, "WM/", 3)) |
166 key += 3; | 174 key += 3; |
167 av_metadata_set(&s->metadata, key, value); | 175 av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL); |
168 } | 176 } |
169 | 177 |
170 static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) | 178 static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) |
171 { | 179 { |
172 ASFContext *asf = s->priv_data; | 180 ASFContext *asf = s->priv_data; |