diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-05-12 22:39:30 +0200 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-05-19 12:29:30 +0200 |
commit | e5fcf3646acd633bfad1806fc778bc33748e6f5f (patch) | |
tree | 3cd6d46f496be32b05e3739a30b8a9200ea0f858 /libavformat | |
parent | 6ad974ae1cd0c828d6dd5a665e830c10c93344b6 (diff) | |
download | ffmpeg-e5fcf3646acd633bfad1806fc778bc33748e6f5f.tar.gz |
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().
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/id3v2.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 97a23c48f1..3b02d2b5b4 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -272,7 +272,7 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding, static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *key) { uint8_t *dst; - int encoding, dict_flags = AV_DICT_DONT_OVERWRITE; + int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL; unsigned genre; if (taglen < 1) @@ -290,7 +290,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1) && genre <= ID3v1_GENRE_MAX) { av_freep(&dst); - dst = ff_id3v1_genre_str[genre]; + dst = av_strdup(ff_id3v1_genre_str[genre]); } else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) { /* dst now contains the key, need to get value */ key = dst; @@ -299,11 +299,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha av_freep(&key); return; } - dict_flags |= AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_STRDUP_KEY; - } - else if (*dst) - dict_flags |= AV_DICT_DONT_STRDUP_VAL; - else + dict_flags |= AV_DICT_DONT_STRDUP_KEY; + } else if (!*dst) av_freep(&dst); if (dst) |