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