History

lavf/id3v2: always strdup the value.

This simplifies the code but also fix a warning: ff_id3v1_genre_str array contains const strings so do the string dup now instead of in av_dict_set().

Clément Bœsch committed 14 years ago

Commit e5fcf361 parent 6ad974a1 file · +4 −7Browse files

Unified · Split

libavformat/id3v2.c+4−7
@@ -272,7 +272,7 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding, · 271 unmodified lines
272272 static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *key)
273273 {
274274 uint8_t *dst;
275− int encoding, dict_flags = AV_DICT_DONT_OVERWRITE;
275+ int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL;
276276 unsigned genre;
277277
278278 if (taglen < 1)
@@ -290,7 +290,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha · 11 unmodified lines
290290 && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
291291 && genre <= ID3v1_GENRE_MAX) {
292292 av_freep(&dst);
293− dst = ff_id3v1_genre_str[genre];
293+ dst = av_strdup(ff_id3v1_genre_str[genre]);
294294 } else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) {
295295 /* dst now contains the key, need to get value */
296296 key = dst;
@@ -299,11 +299,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha · 2 unmodified lines
299299 av_freep(&key);
300300 return;
301301 }
302− dict_flags |= AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_STRDUP_KEY;
303− }
304− else if (*dst)
305− dict_flags |= AV_DICT_DONT_STRDUP_VAL;
306− else
302+ dict_flags |= AV_DICT_DONT_STRDUP_KEY;
303+ } else if (!*dst)
307304 av_freep(&dst);
308305
309306 if (dst)

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