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().
Unified · Split
| @@ -272,7 +272,7 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding, · 271 unmodified lines | ||
| 272 | 272 | static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *key) |
| 273 | 273 | { |
| 274 | 274 | 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; | |
| 276 | 276 | unsigned genre; |
| 277 | 277 | |
| 278 | 278 | if (taglen < 1) |
| @@ -290,7 +290,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha · 11 unmodified lines | ||
| 290 | 290 | && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1) |
| 291 | 291 | && genre <= ID3v1_GENRE_MAX) { |
| 292 | 292 | av_freep(&dst); |
| 293 | − dst = ff_id3v1_genre_str[genre]; | |
| 293 | + dst = av_strdup(ff_id3v1_genre_str[genre]); | |
| 294 | 294 | } else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) { |
| 295 | 295 | /* dst now contains the key, need to get value */ |
| 296 | 296 | key = dst; |
| @@ -299,11 +299,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha · 2 unmodified lines | ||
| 299 | 299 | av_freep(&key); |
| 300 | 300 | return; |
| 301 | 301 | } |
| 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) | |
| 307 | 304 | av_freep(&dst); |
| 308 | 305 | |
| 309 | 306 | if (dst) |